diff --git a/sys/db/query_builder.php b/sys/db/query_builder.php index fce6e5b..ff8a286 100644 --- a/sys/db/query_builder.php +++ b/sys/db/query_builder.php @@ -508,7 +508,10 @@ class Query_Builder { public function delete($table, $where='') { // Set the where clause - $this->where($where); + if ( ! empty($where)) + { + $this->where($where); + } // Create the SQL and parameters $sql = $this->_compile("delete", $table); @@ -618,7 +621,7 @@ class Query_Builder { break; } - //echo $sql.'
'; + echo $sql.'
'; return $sql; } diff --git a/tests/databases/firebird-qb.php b/tests/databases/firebird-qb.php index 25b17fb..fd543ce 100644 --- a/tests/databases/firebird-qb.php +++ b/tests/databases/firebird-qb.php @@ -32,7 +32,7 @@ class FirebirdQBTest extends UnitTestCase { $params->pass = 'masterkey'; $this->qb = new Query_Builder($params); - //echo '
Firebird Queries
'; + echo '
Firebird Queries
'; } function TestQBGet() @@ -126,4 +126,11 @@ class FirebirdQBTest extends UnitTestCase { $this->assertTrue($query); } + + function TestDelete() + { + $query = $this->qb->where('id', 4)->delete('create_test'); + + $this->assertTrue($query); + } } \ No newline at end of file diff --git a/tests/databases/sqlite-qb.php b/tests/databases/sqlite-qb.php index f080edb..3a6e7f3 100644 --- a/tests/databases/sqlite-qb.php +++ b/tests/databases/sqlite-qb.php @@ -28,7 +28,7 @@ $params->host = 'localhost'; $this->qb = new Query_Builder($params); - //echo '
SQLite Queries
'; + echo '
SQLite Queries
'; } function TestGet() @@ -120,4 +120,11 @@ $this->assertIsA($query, 'PDOStatement'); } + + function TestDelete() + { + $query = $this->qb->where('id', 4)->delete('create_test'); + + $this->assertIsA($query, 'PDOStatement'); + } } \ No newline at end of file diff --git a/tests/test_dbs/FB_TEST_DB.FDB b/tests/test_dbs/FB_TEST_DB.FDB index 776d51a..b176515 100755 Binary files a/tests/test_dbs/FB_TEST_DB.FDB and b/tests/test_dbs/FB_TEST_DB.FDB differ