From da6d240d7b8615b5ae628496c42cb216658eb6e4 Mon Sep 17 00:00:00 2001 From: Derek Allard Date: Wed, 19 Dec 2007 14:49:29 +0000 Subject: Added support for limit() into update() statements in Active Record. --- system/database/DB_active_rec.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'system/database/DB_active_rec.php') diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php index 473685874..4a88bd816 100644 --- a/system/database/DB_active_rec.php +++ b/system/database/DB_active_rec.php @@ -826,7 +826,7 @@ class CI_DB_active_record extends CI_DB_driver { * @param mixed the where clause * @return object */ - function update($table = '', $set = NULL, $where = null) + function update($table = '', $set = NULL, $where = null, $limit = NULL) { if ( ! is_null($set)) { @@ -860,8 +860,13 @@ class CI_DB_active_record extends CI_DB_driver { { $this->where($where); } + + if ($limit != null) + { + $this->limit($limit); + } - $sql = $this->_update($this->dbprefix.$table, $this->ar_set, $this->ar_where); + $sql = $this->_update($this->dbprefix.$table, $this->ar_set, $this->ar_where, $this->ar_limit); $this->_reset_write(); return $this->query($sql); @@ -1101,6 +1106,7 @@ class CI_DB_active_record extends CI_DB_driver { $this->ar_set = array(); $this->ar_from = array(); $this->ar_where = array(); + $this->ar_limit = FALSE; } } -- cgit v1.2.3-24-g4f1b