summaryrefslogtreecommitdiffstats
path: root/system/database/DB_driver.php
diff options
context:
space:
mode:
Diffstat (limited to 'system/database/DB_driver.php')
-rw-r--r--system/database/DB_driver.php53
1 files changed, 26 insertions, 27 deletions
diff --git a/system/database/DB_driver.php b/system/database/DB_driver.php
index b7c6b4e8e..10306d721 100644
--- a/system/database/DB_driver.php
+++ b/system/database/DB_driver.php
@@ -1118,31 +1118,19 @@ abstract class CI_DB_driver {
* Generates a platform-specific update string from the supplied data
*
* @param string the table name
- * @param array the update data
- * @param array the where clause
- * @param array the orderby clause
- * @param array the limit clause
- * @param array the like clause
* @return string
*/
- protected function _update($table, $values, $where, $orderby = array(), $limit = FALSE, $like = array())
+ protected function _update($table, $values)
{
foreach ($values as $key => $val)
{
$valstr[] = $key.' = '.$val;
}
- $where = empty($where) ? '' : ' WHERE '.implode(' ', $where);
-
- if ( ! empty($like))
- {
- $where .= ($where === '' ? ' WHERE ' : ' AND ').implode(' ', $like);
- }
-
return 'UPDATE '.$table.' SET '.implode(', ', $valstr)
- .$where
- .(count($orderby) > 0 ? ' ORDER BY '.implode(', ', $orderby) : '')
- .($limit ? ' LIMIT '.$limit : '');
+ .$this->_compile_where()
+ .(empty($this->qb_orderby) ? '' : ' ORDER BY '.implode(', ', $this->qb_orderby))
+ .($this->qb_limit ? ' LIMIT '.(int) $this->qb_limit : '');
}
// --------------------------------------------------------------------
@@ -1155,7 +1143,7 @@ abstract class CI_DB_driver {
*/
protected function _has_operator($str)
{
- return (bool) preg_match('/(\s|<|>|!|=|IS NULL|IS NOT NULL|BETWEEN)/i', trim($str));
+ return (bool) preg_match('/(<|>|!|=|\sIS NULL|\sIS NOT NULL|\sBETWEEN|\sLIKE|\sIN\s*\(|\s)/i', trim($str));
}
// --------------------------------------------------------------------
@@ -1169,18 +1157,29 @@ abstract class CI_DB_driver {
protected function _get_operator($str)
{
static $_operators = array(
- '\s*(?:<|>|!)?=\s*', // =, <=, >=, !=
- '\s*<>?\s*', // <, <>
- '\s*>\s*', // >
- '\s+IS NULL', // IS NULL
- '\s+IS NOT NULL', // IS NOT NULL
- '\s+LIKE\s+', // LIKE
- '\s+NOT LIKE\s+', // NOT LIKE
- '\s+BETWEEN\s+\S+\s+AND\s+\S+', // BETWEEN value AND value
- '\s+IN\s*\([^\)]+\)', // IN(list)
- '\s+NOT IN\s*\([^\)]+\)' // NOT IN (list)
+ '\s*(?:<|>|!)?=\s*', // =, <=, >=, !=
+ '\s*<>?\s*', // <, <>
+ '\s*>\s*', // >
+ '\s+IS NULL', // IS NULL
+ '\s+IS NOT NULL', // IS NOT NULL
+ '\s+BETWEEN\s+\S+\s+AND\s+\S+', // BETWEEN value AND value
+ '\s+IN\s*\([^\)]+\)', // IN(list)
+ '\s+NOT IN\s*\([^\)]+\)' // NOT IN (list)
+ );
+
+ static $_like = array(
+ '\s+LIKE\s+\S+', // LIKE 'expr'
+ '\s+NOT LIKE\s+\S+', // NOT LIKE 'expr'
);
+ if ($this->_like_escape_str !== '')
+ {
+ $_like[0] .= preg_quote(trim(sprintf($this->_like_escape_str, $this->_like_escape_chr)));
+ $_like[1] .= preg_quote(trim(sprintf($this->_like_escape_str, $this->_like_escape_chr)));
+ }
+
+ $_operators = array_merge($_operators, $_like);
+
return preg_match('/'.implode('|', $_operators).'/i', $str, $match)
? $match[0] : FALSE;
}