summaryrefslogtreecommitdiffstats
path: root/system/database
diff options
context:
space:
mode:
authorDerek Allard <derek.allard@ellislab.com>2007-12-20 21:09:22 +0100
committerDerek Allard <derek.allard@ellislab.com>2007-12-20 21:09:22 +0100
commit41f60d44e37cc52d41a49d0d640f71761a82abe7 (patch)
tree3a1e99d67fb20c42dffda2d45bd0ed7353fef3e1 /system/database
parentaa7f769c1e6f46171f2fbc15f43428207c02abcb (diff)
Added the ability to pass an array of tables to the delete() statement in Active Record.
Diffstat (limited to 'system/database')
-rw-r--r--system/database/DB_active_rec.php23
1 files changed, 19 insertions, 4 deletions
diff --git a/system/database/DB_active_rec.php b/system/database/DB_active_rec.php
index dfa0a3efb..d48d1c5bd 100644
--- a/system/database/DB_active_rec.php
+++ b/system/database/DB_active_rec.php
@@ -925,11 +925,13 @@ class CI_DB_active_record extends CI_DB_driver {
* Compiles a delete string and runs the query
*
* @access public
- * @param string the table to retrieve the results from
+ * @param mixed the table(s) to delete from. String or array
* @param mixed the where clause
+ * @param mixed the limit clause
+ * @param boolean
* @return object
*/
- function delete($table = '', $where = '', $limit = NULL)
+ function delete($table = '', $where = '', $limit = NULL, $reset_data = TRUE)
{
if ($table == '')
{
@@ -945,6 +947,16 @@ class CI_DB_active_record extends CI_DB_driver {
$table = $this->ar_from[0];
}
+ if (is_array($table))
+ {
+ foreach($table as $single_table)
+ {
+ $this->delete($this->dbprefix.$single_table, $where, $limit, FALSE);
+ }
+ $this->_reset_write();
+ return;
+ }
+
if ($where != '')
{
$this->where($where);
@@ -963,10 +975,13 @@ class CI_DB_active_record extends CI_DB_driver {
}
return FALSE;
}
-
+
$sql = $this->_delete($this->dbprefix.$table, $this->ar_where, $this->ar_limit);
- $this->_reset_write();
+ if ($reset_data)
+ {
+ $this->_reset_write();
+ }
return $this->query($sql);
}