From fd4b8d9f45d1707035021bc19b8d5bc17ede66ce Mon Sep 17 00:00:00 2001 From: wei <> Date: Mon, 12 Feb 2007 12:46:11 +0000 Subject: Add IBM DB2 driver for active record. --- .../Data/ActiveRecord/Vendor/TMysqlMetaData.php | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'framework/Data/ActiveRecord/Vendor/TMysqlMetaData.php') diff --git a/framework/Data/ActiveRecord/Vendor/TMysqlMetaData.php b/framework/Data/ActiveRecord/Vendor/TMysqlMetaData.php index 0cbd0b7c..03aba53f 100644 --- a/framework/Data/ActiveRecord/Vendor/TMysqlMetaData.php +++ b/framework/Data/ActiveRecord/Vendor/TMysqlMetaData.php @@ -1,4 +1,4 @@ - 0 ? $sql : ''; } - protected function getOrdering($by, $direction) + public function getSearchRegExpCriteria($fields, $keywords) { - $dir = strtolower($direction) == 'desc' ? 'DESC' : 'ASC'; - return $this->getColumn($by)->getName(). ' '.$dir; + if(strlen(trim($keywords)) == 0) return ''; + $words = preg_split('/\s/', preg_quote($keywords, '\'')); + $result = array(); + foreach($fields as $field) + { + $column = $this->getColumn($field); + $result[] = $this->getRegexpCriteriaStr($column->getName(), $words); + } + return '('.implode(' OR ', $result).')'; + } + + protected function getRegexpCriteriaStr($column, $words) + { + $regexp = implode('|', $words); + return "({$column} REGEXP '{$regexp}')"; } + } ?> \ No newline at end of file -- cgit v1.2.3