From 5f56246efd8ae86b327835ddaf67bc0d726700a3 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 9 Apr 2012 12:06:35 +0300 Subject: Fix AR delete() for Oracle --- system/database/drivers/oci8/oci8_driver.php | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'system/database/drivers/oci8/oci8_driver.php') diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php index 6e225ee1f..a452d51ed 100644 --- a/system/database/drivers/oci8/oci8_driver.php +++ b/system/database/drivers/oci8/oci8_driver.php @@ -632,24 +632,19 @@ class CI_DB_oci8_driver extends CI_DB { * * @param string the table name * @param array the where clause + * @param array the like clause * @param string the limit clause * @return string */ protected function _delete($table, $where = array(), $like = array(), $limit = FALSE) { - $conditions = ''; - if (count($where) > 0 OR count($like) > 0) - { - $conditions = "\nWHERE ".implode("\n", $this->ar_where); + $conditions = array(); - if (count($where) > 0 && count($like) > 0) - { - $conditions .= ' AND '; - } - $conditions .= implode("\n", $like); - } + empty($where) OR $conditions[] = implode(' ', $where); + empty($like) OR $conditions[] = implode(' ', $like); + empty($limit) OR $conditions[] = 'rownum <= '.$limit; - return 'DELETE FROM '.$table.$conditions.( ! $limit ? '' : ' LIMIT '.$limit); + return 'DELETE FROM '.$table.(empty($conditions) ? '' : ' WHERE '.implode(' AND ', $conditions)); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b From c01d31685ad365c6bf3e833c03d7f8a3402c0ec7 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 9 Apr 2012 12:55:11 +0300 Subject: Added a default _delete() method to CI_DB_active_record --- system/database/drivers/oci8/oci8_driver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'system/database/drivers/oci8/oci8_driver.php') diff --git a/system/database/drivers/oci8/oci8_driver.php b/system/database/drivers/oci8/oci8_driver.php index a452d51ed..1b66178c6 100644 --- a/system/database/drivers/oci8/oci8_driver.php +++ b/system/database/drivers/oci8/oci8_driver.php @@ -644,7 +644,7 @@ class CI_DB_oci8_driver extends CI_DB { empty($like) OR $conditions[] = implode(' ', $like); empty($limit) OR $conditions[] = 'rownum <= '.$limit; - return 'DELETE FROM '.$table.(empty($conditions) ? '' : ' WHERE '.implode(' AND ', $conditions)); + return 'DELETE FROM '.$table.(count($conditions) > 0 ? ' WHERE '.implode(' AND ', $conditions) : ''); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b