summaryrefslogtreecommitdiff
path: root/framework/Data/ActiveRecord/Vendor/TMysqlMetaData.php
diff options
context:
space:
mode:
Diffstat (limited to 'framework/Data/ActiveRecord/Vendor/TMysqlMetaData.php')
-rw-r--r--framework/Data/ActiveRecord/Vendor/TMysqlMetaData.php22
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