From 7a6237851105059b29ec9293560621e9e2aeab11 Mon Sep 17 00:00:00 2001 From: tof <> Date: Thu, 26 Jul 2007 13:00:36 +0000 Subject: Add primilary Oracle support. --- .../Data/Common/Oracle/TOracleCommandBuilder.php | 70 ++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 framework/Data/Common/Oracle/TOracleCommandBuilder.php (limited to 'framework/Data/Common/Oracle/TOracleCommandBuilder.php') diff --git a/framework/Data/Common/Oracle/TOracleCommandBuilder.php b/framework/Data/Common/Oracle/TOracleCommandBuilder.php new file mode 100644 index 00000000..5d793e60 --- /dev/null +++ b/framework/Data/Common/Oracle/TOracleCommandBuilder.php @@ -0,0 +1,70 @@ + + * @link http://www.pradosoft.com/ + * @copyright Copyright © 2005-2007 PradoSoft + * @license http://www.pradosoft.com/license/ + * @version $Id$ + * @package System.Data.Common + */ + +Prado::using('System.Data.Common.TDbCommandBuilder'); + +/** + * TOracleCommandBuilder provides specifics methods to create limit/offset query commands + * for Oracle database. + * + * @author Marcos Nobre + * @version $Id$ + * @package System.Data.Common + * @since 3.1.1 + */ +class TOracleCommandBuilder extends TDbCommandBuilder +{ + /** + * Overrides parent implementation. Only column of type text or character (and its variants) + * accepts the LIKE criteria. + * @param array list of column id for potential search condition. + * @param string string of keywords + * @return string SQL search condition matching on a set of columns. + */ + public function getSearchExpression($fields, $keywords) + { + $columns = array(); + foreach($fields as $field) + { + if($this->isSearchableColumn($this->getTableInfo()->getColumn($field))) + $columns[] = $field; + } + return parent::getSearchExpression($columns, $keywords); + } + /** + * + * @return boolean true if column can be used for LIKE searching. + */ + protected function isSearchableColumn($column) + { + $type = strtolower($column->getDbType()); + return $type === 'character varying' || $type === 'varchar2' || + $type === 'character' || $type === 'char' || $type === 'text'; + } + + /** + * Overrides parent implementation to use PostgreSQL's ILIKE instead of LIKE (case-sensitive). + * @param string column name. + * @param array keywords + * @return string search condition for all words in one column. + */ + protected function getSearchCondition($column, $words) + { + $conditions=array(); + foreach($words as $word) + $conditions[] = $column.' LIKE '.$this->getDbConnection()->quoteString('%'.$word.'%'); + return '('.implode(' AND ', $conditions).')'; + } + +} + +?> \ No newline at end of file -- cgit v1.2.3