From e2cb2242caf642c6440b6a1d0fc89b3826e85955 Mon Sep 17 00:00:00 2001 From: tag Date: Wed, 21 Nov 2012 17:24:55 -0500 Subject: [PATCH] Fixed query logging for delete_many; added unit test for delete_many --- idiorm.php | 1 + test/test_queries.php | 10 +++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) mode change 100644 => 100755 test/test_queries.php diff --git a/idiorm.php b/idiorm.php index 9424d4af..2b8917c3 100644 --- a/idiorm.php +++ b/idiorm.php @@ -1360,6 +1360,7 @@ public function delete_many() { $this->_quote_identifier($this->_table_name), $this->_build_where(), )); + self::_log_query($query, $this->_values); $statement = self::$_db->prepare($query); return $statement->execute($this->_values); } diff --git a/test/test_queries.php b/test/test_queries.php old mode 100644 new mode 100755 index bcd4c7ec..984b407e --- a/test/test_queries.php +++ b/test/test_queries.php @@ -291,20 +291,24 @@ $expected = "DELETE FROM `widget` WHERE `id` = '1'"; Tester::check_equal("Delete data", $expected); + $widget = ORM::for_table('widget')->where_equal('age', 10)->delete_many(); + $expected = "DELETE FROM `widget` WHERE `age` = '10'"; + Tester::check_equal("Delete many", $expected); + // Regression tests $widget = ORM::for_table('widget')->select('widget.*')->find_one(); $expected = "SELECT `widget`.* FROM `widget` LIMIT 1"; Tester::check_equal("Issue #12 - incorrect quoting of column wildcard", $expected); - + $widget = ORM::for_table('widget')->where_raw('username LIKE "ben%"')->find_many(); $expected = 'SELECT * FROM `widget` WHERE username LIKE "ben%"'; Tester::check_equal('Issue #57 - _log_query method raises a warning when query contains "%"', $expected); - + $widget = ORM::for_table('widget')->where_raw('comments LIKE "has been released?%"')->find_many(); $expected = 'SELECT * FROM `widget` WHERE comments LIKE "has been released?%"'; Tester::check_equal('Issue #57 - _log_query method raises a warning when query contains "?"', $expected); - + // Tests that alter Idiorm's config are done last ORM::configure('id_column', 'primary_key');