diff --git a/lib/Constants.php b/lib/Constants.php index 16c6978..6ac5df0 100644 --- a/lib/Constants.php +++ b/lib/Constants.php @@ -5,7 +5,7 @@ /** * ezsqlModel Constants */ - \defined('EZSQL_VERSION') or \define('EZSQL_VERSION', '4.0.4'); + \defined('EZSQL_VERSION') or \define('EZSQL_VERSION', '4.0.5'); \defined('OBJECT') or \define('OBJECT', 'OBJECT'); \defined('ARRAY_A') or \define('ARRAY_A', 'ARRAY_A'); \defined('ARRAY_N') or \define('ARRAY_N', 'ARRAY_N'); diff --git a/lib/Database/ez_mysqli.php b/lib/Database/ez_mysqli.php index 8015c28..20c3e5b 100644 --- a/lib/Database/ez_mysqli.php +++ b/lib/Database/ez_mysqli.php @@ -273,6 +273,13 @@ private function fetch_prepared_result(&$stmt, $query) public function query_prepared(string $query, array $param = null) { $stmt = $this->dbh->prepare($query); + if (!$stmt instanceof \mysqli_stmt) { + if ($this->isTransactional) + throw new \Exception($this->getLast_Error()); + + return false; + } + $params = []; $types = \array_reduce($param, function ($string, &$arg) use (&$params) { @@ -422,8 +429,12 @@ public function query(string $query, bool $use_prepare = false) $this->result = \mysqli_query($this->dbh, $query); - if ($this->processQueryResult($query) === false) + if ($this->processQueryResult($query) === false) { + if ($this->isTransactional) + throw new \Exception($this->getLast_Error()); + return false; + } // disk caching of queries $this->store_cache($query, $this->is_insert); diff --git a/lib/Database/ez_pdo.php b/lib/Database/ez_pdo.php index 016cf88..f53b236 100644 --- a/lib/Database/ez_pdo.php +++ b/lib/Database/ez_pdo.php @@ -423,8 +423,12 @@ public function query(string $query, bool $use_prepare = false) $this->database->getIsFile()); } - if ($this->processQuery($query, $param) === false) + if ($this->processQuery($query, $param) === false) { + if ($this->isTransactional) + throw new \PDOException($this->getLast_Error()); + return false; + } // disk caching of queries $this->store_cache($query, $this->is_insert); diff --git a/lib/Database/ez_pgsql.php b/lib/Database/ez_pgsql.php index 1241d50..4eddfe5 100644 --- a/lib/Database/ez_pgsql.php +++ b/lib/Database/ez_pgsql.php @@ -297,8 +297,12 @@ public function query(string $query, bool $use_prepare = false) $this->result = @\pg_query($this->dbh, $query); } - if ($this->processQueryResult($query) === false) + if ($this->processQueryResult($query) === false) { + if ($this->isTransactional) + throw new \Exception($this->getLast_Error()); + return false; + } // disk caching of queries $this->store_cache($query, $this->is_insert); diff --git a/lib/Database/ez_sqlite3.php b/lib/Database/ez_sqlite3.php index eff1cb9..d7c33b1 100644 --- a/lib/Database/ez_sqlite3.php +++ b/lib/Database/ez_sqlite3.php @@ -137,6 +137,13 @@ public function getArgType($arg) public function query_prepared(string $query, array $param = null) { $stmt = $this->dbh->prepare($query); + if (!$stmt instanceof \SQLite3Stmt) { + if ($this->isTransactional) + throw new \Exception($this->getLast_Error()); + + return false; + } + foreach ($param as $index => $val) { // indexing start from 1 in Sqlite3 statement if (\is_array($val)) { @@ -272,8 +279,12 @@ public function query(string $query, bool $use_prepare = false) $this->result = $this->dbh->query($query); } - if ($this->processQueryResult($query) === false) + if ($this->processQueryResult($query) === false) { + if ($this->isTransactional) + throw new \Exception($this->getLast_Error()); + return false; + } if (!empty($param) && \is_array($param) && $this->isPrepareOn()) $this->result->finalize(); @@ -316,19 +327,19 @@ public function handle() */ public function beginTransaction() { - $this->dbh->exec('BEGIN'); + $this->dbh->exec('BEGIN;'); $this->isTransactional = true; } public function commit() { - $this->dbh->exec('COMMIT'); + $this->dbh->exec('COMMIT;'); $this->isTransactional = false; } public function rollback() { - $this->dbh->exec('ROLLBACK'); + $this->dbh->exec('ROLLBACK;'); $this->isTransactional = false; } } \ No newline at end of file diff --git a/lib/Database/ez_sqlsrv.php b/lib/Database/ez_sqlsrv.php index 0eb9e28..cfb1466 100644 --- a/lib/Database/ez_sqlsrv.php +++ b/lib/Database/ez_sqlsrv.php @@ -301,8 +301,12 @@ public function query(string $query, bool $use_prepare = false) $this->result = @\sqlsrv_query($this->dbh, $query); } - if ($this->processQueryResult($query) === false) + if ($this->processQueryResult($query) === false) { + if ($this->isTransactional) + throw new \Exception($this->getLast_Error()); + return false; + } // disk caching of queries $this->store_cache($query, $this->is_insert); diff --git a/lib/ezFunctions.php b/lib/ezFunctions.php index 45175fd..0f43128 100644 --- a/lib/ezFunctions.php +++ b/lib/ezFunctions.php @@ -450,7 +450,7 @@ function update($table = '', $keyValue, ...$args) { : false; } - function delete($table = '', ...$args) { + function deleting($table = '', ...$args) { $ezQuery = \getInstance(); return ($ezQuery instanceOf DatabaseInterface) ? $ezQuery->delete($table, ...$args) diff --git a/lib/ezQuery.php b/lib/ezQuery.php index 20577fa..d0e7883 100644 --- a/lib/ezQuery.php +++ b/lib/ezQuery.php @@ -779,7 +779,7 @@ public function create(string $table = null, ...$schemas) if (empty($table) || empty($schemas) || empty($vendor)) return false; - $sql = 'CREATE TABLE '.$table.'( '; + $sql = 'CREATE TABLE IF NOT EXISTS '.$table.'( '; $skipSchema = false; if (\is_string($schemas[0])) { diff --git a/tests/ezFunctionsTest.php b/tests/ezFunctionsTest.php index 846b3d1..cec4580 100644 --- a/tests/ezFunctionsTest.php +++ b/tests/ezFunctionsTest.php @@ -301,8 +301,8 @@ public function testUpdate() { /** * @test delete */ - public function testDelete() { - $this->assertFalse(delete('field', 'data', 'data2')); + public function testDeleting() { + $this->assertFalse(deleting('field', 'data', 'data2')); } /** diff --git a/tests/mysqli/mysqliTest.php b/tests/mysqli/mysqliTest.php index 7ae8df2..4d1d61e 100644 --- a/tests/mysqli/mysqliTest.php +++ b/tests/mysqli/mysqliTest.php @@ -420,6 +420,93 @@ public function testSelecting() } } + /** + * @covers ezsql\Database\ez_mysqli::commit + * @covers ezsql\Database\ez_mysqli::beginTransaction + * @covers ezsql\Database\ez_mysqli::query + * @covers ezsql\Database\ez_mysqli::processQueryResult + */ + public function testBeginTransactionCommit() + { + $this->object->connect(); + $this->object->query('CREATE TABLE unit_test(id int(11) NOT NULL AUTO_INCREMENT, test_key varchar(50), PRIMARY KEY (ID))ENGINE=MyISAM DEFAULT CHARSET=utf8'); + $this->object->query('"ALTER TABLE unit_test Type=InnoDB"'); + + $commit = null; + try { + $commit = true; + $this->object->beginTransaction(); + $this->object->insert('unit_test', array('id'=>'1', 'test_key'=>'testing 1' )); + $this->object->insert('unit_test', array('id'=>'2', 'test_key'=>'testing 2' )); + $this->object->insert('unit_test', array('id'=>'3', 'test_key'=>'testing 3' )); + $this->object->commit(); + } catch(\Exception $ex) { + $commit = false; + $this->object->rollback(); + echo ("Error! This rollback message shouldn't have been displayed: ").$ex->getMessage(); + } + + if ($commit) { + $result = $this->object->selecting('unit_test'); + $i = 1; + foreach ($result as $row) { + $this->assertEquals($i, $row->id); + $this->assertEquals('testing ' . $i, $row->test_key); + ++$i; + } + + $this->assertEquals(0, $this->object->drop('unit_test')); + } + } + + /** + * @covers ezsql\Database\ez_mysqli::rollback + * @covers ezsql\Database\ez_mysqli::beginTransaction + * @covers ezsql\Database\ez_mysqli::query + * @covers ezsql\Database\ez_mysqli::processQueryResult + */ + public function testBeginTransactionRollback() + { + $this->object->connect(); + $this->object->query('CREATE TABLE unit_test(id int(11) NOT NULL AUTO_INCREMENT, test_key varchar(50), PRIMARY KEY (ID)'); + $this->object->query('"ALTER TABLE unit_test Type=InnoDB"'); + + $commit = null; + try { + $commit = true; + $this->object->beginTransaction(); + $this->object->insert('unit_test', array('id'=>'1', 'test_key'=>'testing 1' )); + $this->object->insert('unit_test', array('id'=>'2', 'test_key'=>'testing 2' )); + $this->object->insert('unit_test', array('idx' => 1, 'test_key2'=>'testing 1' )); + $this->object->commit(); + } catch(\Exception $ex) { + $commit = false; + $this->object->rollback(); + } + + if ($commit) { + echo ("Error! This message shouldn't have been displayed."); + $result = $this->object->selecting('unit_test'); + $i = 1; + foreach ($result as $row) { + $this->assertEquals('should not be seen ' . $i, $row->test_key); + ++$i; + } + $this->object->drop('unit_test'); + } else { + //echo ("Error! rollback."); + $result = $this->object->selecting('unit_test'); + $i = 1; + foreach ($result as $row) { + $this->assertEquals('should not be seen ' . $i, $row->test_key); + ++$i; + } + + $this->assertEquals(0, $result); + $this->object->drop('unit_test'); + } + } + /** * @covers ezsql\Database\ez_mysqli::query * @covers ezsql\Database\ez_mysqli::processQueryResult diff --git a/tests/pdo/pdo_mysqlTest.php b/tests/pdo/pdo_mysqlTest.php index 5e419dc..20e489b 100644 --- a/tests/pdo/pdo_mysqlTest.php +++ b/tests/pdo/pdo_mysqlTest.php @@ -320,8 +320,9 @@ public function testBeginTransactionCommit() $this->object->insert('unit_test', array('id'=>'3', 'test_key'=>'testing 3' )); $this->object->commit(); } catch(\PDOException $ex) { + $commit = false; $this->object->rollback(); - $this->fail("Error! This message shouldn't have been displayed."); + echo ("Error! This rollback message shouldn't have been displayed: ").$ex->getMessage(); } if ($commit) { @@ -333,23 +334,7 @@ public function testBeginTransactionCommit() ++$i; } - $where = array('test_key', '=', 'testing 2'); - $result = select('unit_test', 'id', $where); - foreach ($result as $row) { - $this->assertEquals(2, $row->id); - } - - $result = $this->object->selecting('unit_test', 'test_key', array( 'id', '=', '3' )); - foreach ($result as $row) { - $this->assertEquals('testing 3', $row->test_key); - } - - $result = $this->object->selecting('unit_test', array ('test_key'), eq('id', 1)); - foreach ($result as $row) { - $this->assertEquals('testing 1', $row->test_key); - } - - $this->assertEquals(0, $this->object->query('DROP TABLE unit_test')); + $this->assertEquals(0, $this->object->drop('unit_test')); } } @@ -372,7 +357,9 @@ public function testBeginTransactionRollback() try { $commit = true; $this->object->beginTransaction(); - $this->object->insert('unit_test', array( 0 => 3, 'test_key'=>'testing 3' )); + $this->object->insert('unit_test', array('id'=>'1', 'test_key'=>'testing 1' )); + $this->object->insert('unit_test', array('id'=>'2', 'test_key'=>'testing 2' )); + $this->object->insert('unit_test', array( 'idx' => 3, 'test_key'=>'testing 3' )); $this->object->commit(); } catch(\PDOException $ex) { $commit = false; @@ -380,18 +367,25 @@ public function testBeginTransactionRollback() } if ($commit) { - //echo ("Error! This message shouldn't have been displayed."); + echo ("Error! This message shouldn't have been displayed."); $result = $this->object->selecting('unit_test'); $i = 1; foreach ($result as $row) { - $this->assertEquals('should be seen ' . $i, $row->test_key); + $this->assertEquals('should not be seen ' . $i, $row->test_key); ++$i; } - $this->assertEquals(0, $this->object->query('DROP TABLE unit_test')); + $this->object->drop('unit_test'); } else { + //echo ("Error! rollback."); $result = $this->object->selecting('unit_test'); + $i = 1; + foreach ($result as $row) { + $this->assertEquals('should not be seen ' . $i, $row->test_key); + ++$i; + } + $this->assertEquals(0, $result); - $this->assertEquals(0, $this->object->query('DROP TABLE unit_test')); + $this->object->drop('unit_test'); } } diff --git a/tests/postgresql/postgresqlTest.php b/tests/postgresql/postgresqlTest.php index 8a6aa71..891fe61 100644 --- a/tests/postgresql/postgresqlTest.php +++ b/tests/postgresql/postgresqlTest.php @@ -286,6 +286,102 @@ public function testSelecting() $this->assertEquals(0, $this->object->query('DROP TABLE unit_test')); } + /** + * @covers ezsql\ezQuery::selecting + * @covers ezsql\Database\ez_pgsql::commit + * @covers ezsql\Database\ez_pgsql::beginTransaction + * @covers ezsql\Database\ez_pgsql::query + * @covers ezsql\Database\ez_pgsql::processQueryResult + * @covers ezsql\Database\ez_pgsql::prepareValues + * @covers ezsql\Database\ez_pgsql::query_prepared + */ + public function testBeginTransactionCommit() + { + $this->object->connect(); + $this->object->query('CREATE TABLE unit_test(id serial, test_key varchar(50), test_value varchar(50), PRIMARY KEY (ID))'); + + $commit = null; + try { + $commit = true; + $this->object->beginTransaction(); + $this->object->insert('unit_test', array('test_key'=>'test 1', 'test_value'=>'testing string 1' )); + $this->object->insert('unit_test', array('test_key'=>'test 2', 'test_value'=>'testing string 2' )); + $this->object->insert('unit_test', array('test_key'=>'test 3', 'test_value'=>'testing string 3' )); + $this->object->commit(); + } catch(\Exception $ex) { + $commit = false; + $this->object->rollback(); + echo ("Error! This rollback message shouldn't have been displayed: ").$ex->getMessage(); + } + + if ($commit) { + $result = $this->object->selecting('unit_test'); + $i = 1; + foreach ($result as $row) { + $this->assertEquals($i, $row->id); + $this->assertEquals('testing string ' . $i, $row->test_value); + $this->assertEquals('test ' . $i, $row->test_key); + ++$i; + } + + $this->assertEquals(0, $this->object->drop('unit_test')); + } + } + + /** + * @covers ezsql\Database\ez_pgsql::rollback + * @covers ezsql\Database\ez_pgsql::beginTransaction + * @covers ezsql\Database\ez_pgsql::query + * @covers ezsql\Database\ez_pgsql::processQueryResult + * @covers ezsql\Database\ez_pgsql::prepareValues + * @covers ezsql\Database\ez_pgsql::query_prepared + */ + public function testBeginTransactionRollback() + { + $this->object->connect(); + $this->object->query('CREATE TABLE unit_test(id int(11) NOT NULL AUTO_INCREMENT, test_key varchar(50), PRIMARY KEY (ID)'); + + $commit = null; + try { + $commit = true; + $this->object->beginTransaction(); + $this->object->insert('unit_test', array('test_key'=>'test 1', 'test_value'=>'testing string 1' )); + $this->object->insert('unit_test', array('test_key'=>'test 2', 'test_value'=>'testing string 2' )); + $this->object->insert('unit_test', array('test_key'=>'test 3', 'test_value'=>'testing string 3' )); + $this->object->commit(); + } catch(\Exception $ex) { + $commit = false; + $this->object->rollback(); + } + + if ($commit) { + echo ("Error! This message shouldn't have been displayed."); + $result = $this->object->selecting('unit_test'); + $i = 1; + foreach ($result as $row) { + $this->assertEquals($i, $row->id); + $this->assertEquals('should not be seen ' . $i, $row->test_value); + $this->assertEquals('test ' . $i, $row->test_key); + ++$i; + } + + $this->object->drop('unit_test'); + } else { + //echo ("Error! rollback."); + $result = $this->object->selecting('unit_test'); + $i = 1; + foreach ($result as $row) { + $this->assertEquals($i, $row->id); + $this->assertEquals('should not be seen ' . $i, $row->test_value); + $this->assertEquals('test ' . $i, $row->test_key); + ++$i; + } + + $this->assertEquals(0, $result); + $this->object->drop('unit_test'); + } + } + /** * @covers ezsql\ezQuery::drop * @covers ezsql\ezQuery::create diff --git a/tests/sqlite/sqlite3Test.php b/tests/sqlite/sqlite3Test.php index 253fff5..59d6b19 100644 --- a/tests/sqlite/sqlite3Test.php +++ b/tests/sqlite/sqlite3Test.php @@ -286,6 +286,106 @@ public function testSelecting() } } + /** + * @covers ezsql\ezQuery::selecting + * @covers ezsql\Database\ez_sqlite3::commit + * @covers ezsql\Database\ez_sqlite3::beginTransaction + * @covers ezsql\Database\ez_sqlite3::query + * @covers ezsql\Database\ez_sqlite3::processQueryResult + * @covers ezsql\Database\ez_sqlite3::prepareValues + * @covers ezsql\Database\ez_sqlite3::query_prepared + * @covers ezsql\Database\ez_sqlite3::getArgType + */ + public function testBeginTransactionCommit() + { + $this->object->connect(); + $this->object->query('CREATE TABLE IF NOT EXISTS test_table(id integer, test_key varchar(50), test_value varchar(50), PRIMARY KEY (ID))'); + + $commit = null; + try { + $commit = true; + $this->object->beginTransaction(); + $this->object->insert('test_table', array('test_key'=>'test 1', 'test_value'=>'testing string 1' )); + $this->object->insert('test_table', array('test_key'=>'test 2', 'test_value'=>'testing string 2' )); + $this->object->insert('test_table', array('test_key'=>'test 3', 'test_value'=>'testing string 3' )); + $this->object->commit(); + } catch(\Exception $ex) { + $commit = false; + $this->object->rollback(); + echo ("Error! This rollback message shouldn't have been displayed: ").$ex->getMessage(); + } + + if ($commit) { + $result = $this->object->selecting('test_table'); + $i = 1; + foreach ($result as $row) { + $this->assertEquals($i, $row->id); + $this->assertEquals('testing string ' . $i, $row->test_value); + $this->assertEquals('test ' . $i, $row->test_key); + ++$i; + } + + $this->assertEquals(0, $this->object->drop('test_table')); + } + } + + /** + * @covers ezsql\ezQuery::selecting + * @covers ezsql\Database\ez_sqlite3::rollback + * @covers ezsql\Database\ez_sqlite3::beginTransaction + * @covers ezsql\Database\ez_sqlite3::query + * @covers ezsql\Database\ez_sqlite3::processQueryResult + * @covers ezsql\Database\ez_sqlite3::prepareValues + * @covers ezsql\Database\ez_sqlite3::query_prepared + * @covers ezsql\Database\ez_sqlite3::getArgType + */ + public function testBeginTransactionRollback() + { + $this->object->query('CREATE TABLE IF NOT EXISTS test_table(id integer, test_key varchar(50), test_value varchar(50), PRIMARY KEY (ID))'); + + $commit = null; + try { + $commit = true; + $this->object->beginTransaction(); + $this->object->insert('test_table', array('test_key'=>'test 1', 'test_value'=>'testing string 1' )); + $this->object->insert('test_table', array('test_key'=>'test 2', 'test_value'=>'testing string 2' )); + $this->object->insert('test_table', array('test_keyx'=>'test 3', 'test_valuex'=>'testing string 3' )); + $this->object->commit(); + } catch(\Exception $ex) { + $commit = false; + $this->object->rollback(); + } + + if ($commit) { + echo ("Error! This message shouldn't have been displayed."); + $result = $this->object->selecting('test_table'); + + $i = 1; + foreach ($result as $row) { + $this->assertEquals($i, $row->id); + $this->assertEquals('should not be seen ' . $i, $row->test_value); + $this->assertEquals('test ' . $i, $row->test_key); + ++$i; + } + + $this->object->drop('test_table'); + } else { + //echo ("Error! rollback."); + $result = $this->object->selecting('test_table'); + + $i = 1; + foreach ($result as $row) { + $this->assertEquals($i, $row->id); + $this->assertEquals('should not be seen ' . $i, $row->test_value); + $this->assertEquals('test ' . $i, $row->test_key); + ++$i; + } + + $this->assertEquals(0, $result); + $this->object->drop('test_table'); + } + } + /** * @covers ezsql\ezQuery::drop * @covers ezsql\ezQuery::create @@ -298,6 +398,8 @@ public function testSelecting() */ public function testQuery_prepared() { $this->object->prepareOff(); + $this->object->drop('prepare_test'); + $this->object->create('prepare_test', column('id', INTEGERS, PRIMARY), column('prepare_key', VARCHAR, 50) diff --git a/tests/sqlsrv/sqlsrvTest.php b/tests/sqlsrv/sqlsrvTest.php index 22938ce..2779c86 100644 --- a/tests/sqlsrv/sqlsrvTest.php +++ b/tests/sqlsrv/sqlsrvTest.php @@ -289,7 +289,106 @@ public function testSelecting() $this->assertEquals('testing 8', $row->test_key); } } - + + /** + * @covers ezsql\ezQuery::selecting + * @covers ezsql\Database\ez_sqlsrv::commit + * @covers ezsql\Database\ez_sqlsrv::beginTransaction + * @covers ezsql\Database\ez_sqlsrv::query + * @covers ezsql\Database\ez_sqlsrv::processQueryResult + * @covers ezsql\Database\ez_sqlsrv::prepareValues + * @covers ezsql\Database\ez_sqlsrv::query_prepared + * @covers ezsql\Database\ez_sqlsrv::get_datatype + */ + public function testBeginTransactionCommit() + { + $this->object->quick_connect(self::TEST_DB_USER, self::TEST_DB_PASSWORD, self::TEST_DB_NAME); + $this->object->query('CREATE TABLE unit_test(id integer, test_key varchar(50), PRIMARY KEY (ID))'); + + $commit = null; + try { + $commit = true; + $this->object->beginTransaction(); + $this->object->insert('unit_test', array('id'=>8, 'test_key'=>'testing 8' )); + $this->object->insert('unit_test', array('id'=>9, 'test_key'=>'testing 9' )); + $this->object->insert('unit_test', array('id'=>10, 'test_key'=>'testing 10' )); + $this->object->commit(); + } catch(\Exception $ex) { + $commit = false; + $this->object->rollback(); + echo ("Error! This rollback message shouldn't have been displayed: ").$ex->getMessage(); + } + + if ($commit) { + $result = $this->object->selecting('unit_test'); + $i = 8; + + foreach ($result as $row) { + $this->assertEquals($i, $row->id); + $this->assertEquals('testing ' . $i, $row->test_key); + ++$i; + } + + $this->object->drop('unit_test'); + } + } + + /** + * @covers ezsql\ezQuery::selecting + * @covers ezsql\Database\ez_sqlsrv::rollback + * @covers ezsql\Database\ez_sqlsrv::beginTransaction + * @covers ezsql\Database\ez_sqlsrv::query + * @covers ezsql\Database\ez_sqlsrv::processQueryResult + * @covers ezsql\Database\ez_sqlsrv::prepareValues + * @covers ezsql\Database\ez_sqlsrv::query_prepared + * @covers ezsql\Database\ez_sqlsrv::get_datatype + */ + public function testBeginTransactionRollback() + { + $this->object->quick_connect(self::TEST_DB_USER, self::TEST_DB_PASSWORD, self::TEST_DB_NAME); + $this->object->query('CREATE TABLE unit_test(id integer, test_key varchar(50), PRIMARY KEY (ID))'); + + $commit = null; + try { + $commit = true; + $this->object->beginTransaction(); + $this->object->insert('unit_test', array('id'=>8, 'test_key'=>'testing 8' )); + $this->object->insert('unit_test', array('id'=>9, 'test_key'=>'testing 9' )); + $this->object->insert('unit_test', array('idx'=>10, 'test_key'=>'testing 10' )); + $this->object->commit(); + } catch(\Exception $ex) { + $commit = false; + $this->object->rollback(); + } + + if ($commit) { + echo ("Error! This message shouldn't have been displayed."); + $result = $this->object->selecting('unit_test'); + $i = 8; + + foreach ($result as $row) { + $this->assertEquals($i, $row->id); + $this->assertEquals('should not be seen ' . $i, $row->test_key); + ++$i; + } + + $this->object->drop('unit_test'); + } else { + //echo ("Error! rollback."); + $result = $this->object->selecting('unit_test'); + $i = 8; + + foreach ($result as $row) { + $this->assertEquals($i, $row->id); + $this->assertEquals('should not be seen ' . $i, $row->test_key); + ++$i; + } + + $this->assertEquals(0, $result); + $this->object->drop('test_table'); + } + } + /** * @covers ezsql\Database\ez_sqlsrv::disconnect * @covers ezsql\Database\ez_sqlsrv::reset