Permalink
Browse files

Fix an update_string() bug

  • Loading branch information...
1 parent 3b72eb5 commit 87f4dc27230debc0af281c9780f2ba939fe07608 @narfbg narfbg committed Oct 31, 2012
Showing with 4 additions and 28 deletions.
  1. +3 −27 system/database/DB_driver.php
  2. +1 −1 system/database/DB_query_builder.php
@@ -1080,43 +1080,19 @@ protected function _insert($table, $keys, $values)
*/
public function update_string($table, $data, $where)
{
- if ($where === '')
+ if (empty($where))
{
return FALSE;
}
+ $this->where($where);
+
$fields = array();
foreach ($data as $key => $val)
{
$fields[$this->protect_identifiers($key)] = $this->escape($val);
}
- if ( ! is_array($where))
- {
- $dest = array($where);
- }
- else
- {
- $dest = array();
- foreach ($where as $key => $val)
- {
- $prefix = (count($dest) === 0) ? '' : ' AND ';
- $key = $this->protect_identifiers($key);
-
- if ($val !== '')
- {
- if ( ! $this->_has_operator($key))
- {
- $key .= ' =';
- }
-
- $val = ' '.$this->escape($val);
- }
-
- $dest[] = $prefix.$key.$val;
- }
- }
-
return $this->_update($this->protect_identifiers($table, TRUE, NULL, FALSE), $fields, $dest);
}
@@ -1575,7 +1575,7 @@ public function update($table = '', $set = NULL, $where = NULL, $limit = NULL)
}
$sql = $this->_update($this->protect_identifiers($this->qb_from[0], TRUE, NULL, FALSE), $this->qb_set);
-
+var_dump($sql);
@it-can

it-can Nov 1, 2012

Contributor

@narfbg you forgot something...

$this->_reset_write();
return $this->query($sql);
}

1 comment on commit 87f4dc2

Contributor

ivantcholakov commented on 87f4dc2 Nov 1, 2012

On the line 1578 there is a var_dump output, probably forgotten?

Please sign in to comment.