diff options
author | Derek Allard <derek.allard@ellislab.com> | 2008-02-05 17:03:50 +0100 |
---|---|---|
committer | Derek Allard <derek.allard@ellislab.com> | 2008-02-05 17:03:50 +0100 |
commit | 32cf7eb132ec688a3b0339f266efa3f064c58a60 (patch) | |
tree | e18b7d714046c2d4f618668286ad9301f82df089 /system/database/drivers/mysql/mysql_driver.php | |
parent | c27bf007eeaf0fa3e6088e30d6b7ea88b7c0b517 (diff) |
Changed the behaviour of Active Record's update() to make the WHERE clause optional (#3395)
Diffstat (limited to 'system/database/drivers/mysql/mysql_driver.php')
-rw-r--r-- | system/database/drivers/mysql/mysql_driver.php | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/system/database/drivers/mysql/mysql_driver.php b/system/database/drivers/mysql/mysql_driver.php index a5082d1b3..372365aeb 100644 --- a/system/database/drivers/mysql/mysql_driver.php +++ b/system/database/drivers/mysql/mysql_driver.php @@ -550,7 +550,11 @@ class CI_DB_mysql_driver extends CI_DB { $orderby = (count($orderby) >= 1)?' ORDER BY '.implode(", ", $orderby):'';
- return "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr)." WHERE ".implode(" ", $where).$orderby.$limit;
+ $sql = "UPDATE ".$this->_escape_table($table)." SET ".implode(', ', $valstr);
+ $sql .= ($where != '' AND count($where) >=1) ? " WHERE ".implode(" ", $where) : '';
+ $sql .= $orderby.$limit;
+
+ return $sql;
}
// --------------------------------------------------------------------
|