diff options
author | wei <> | 2007-02-12 12:46:11 +0000 |
---|---|---|
committer | wei <> | 2007-02-12 12:46:11 +0000 |
commit | fd4b8d9f45d1707035021bc19b8d5bc17ede66ce (patch) | |
tree | 093b8b3f92d4d6421f19a6d1e7c8211817f3d51d /framework/Data/ActiveRecord/Vendor/TMysqlMetaData.php | |
parent | f4c525abc3d4d3f3eecf1019770936e4ca39fd62 (diff) |
Add IBM DB2 driver for active record.
Diffstat (limited to 'framework/Data/ActiveRecord/Vendor/TMysqlMetaData.php')
-rw-r--r-- | framework/Data/ActiveRecord/Vendor/TMysqlMetaData.php | 22 |
1 files changed, 18 insertions, 4 deletions
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 @@ -<?php +<?php
/**
* TMysqlMetaData class file.
*
@@ -48,10 +48,24 @@ class TMysqlMetaData extends TDbMetaDataCommon return strlen($sql) > 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 |