Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added "public" visibility. Added support for LIKE in update() functio…

…n just like in MySQL.
  • Loading branch information...
commit fe73bab4c5fdc7ac3489968daa4e2820e53aa9d5 1 parent 546343f
@kadishmal kadishmal authored
Showing with 10 additions and 13 deletions.
  1. +10 −13 system/database/drivers/cubrid/cubrid_driver.php
View
23 system/database/drivers/cubrid/cubrid_driver.php
@@ -615,7 +615,6 @@ function _insert_batch($table, $keys, $values)
*
* Generates a platform-specific update string from the supplied data
*
- * @access public
* @param string the table name
* @param array the update data
* @param array the where clause
@@ -623,24 +622,22 @@ function _insert_batch($table, $keys, $values)
* @param array the limit clause
* @return string
*/
- function _update($table, $values, $where, $orderby = array(), $limit = FALSE)
+ protected function _update($table, $values, $where, $orderby = array(), $limit = FALSE, $like = array())
{
foreach ($values as $key => $val)
{
- $valstr[] = sprintf('"%s" = %s', $key, $val);
+ $valstr[] = $key.' = '.$val;
}
- $limit = ( ! $limit) ? '' : ' LIMIT '.$limit;
-
- $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
-
- $sql = "UPDATE ".$table." SET ".implode(', ', $valstr);
-
- $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
-
- $sql .= $orderby.$limit;
+ $where = ($where != '' && count($where) > 0) ? ' WHERE '.implode(' ', $where) : '';
+ if (count($like) > 0)
+ {
+ $where .= ($where == '' ? ' WHERE ' : ' AND ').implode(' ', $like);
+ }
- return $sql;
+ return 'UPDATE '.$table.' SET '.implode(', ', $valstr).$where
+ .(count($orderby) > 0 ? ' ORDER BY '.implode(', ', $orderby) : '')
+ .( ! $limit ? '' : ' LIMIT '.$limit);
}
// --------------------------------------------------------------------
Please sign in to comment.
Something went wrong with that request. Please try again.