/**
  * @param array $where
  * @return AbstractModelCollection
  */
 protected function queryMany($where = NULL)
 {
     $collection = $this->getNewCollection();
     $records = $this->db->select($this->tablename, '*', $this->scalarizeWhere($where));
     foreach ($records as $record) {
         $collection->add($this->recordToObject($record));
     }
     return $collection;
 }
 /**
  * @param string $statement
  * @throws DatabaseQueryException
  * @throws DatabaseMigratorException
  */
 protected function executeStatement($statement)
 {
     if (strlen($statement) > 3 && substr(ltrim($statement), 0, 2) != '/*') {
         try {
             $this->db->execute($statement);
         } catch (DatabaseQueryException $ex) {
             $this->db->execute('ROLLBACK;');
             throw $ex;
         }
     }
 }
 /**
  * @test
  * @expectedException \AppZap\PHPFramework\Persistence\DatabaseMigratorException
  * @expectedExceptionCode 1415089456
  */
 public function rollbackOnError()
 {
     Configuration::set('phpframework', 'db.migrator.directory', $this->basePath . '/_migrator/_error/');
     try {
         (new DatabaseMigrator())->migrate();
     } catch (\Exception $e) {
         $this->assertSame(1, count($this->db->query("SHOW TABLES LIKE 'migrator_test_error'")));
         $this->assertSame(1, $this->db->count('migrator_test_error', ['title' => 'test1']));
         $this->assertSame(1, $this->db->count('migrator_test_error'));
         throw $e;
     }
 }
 /**
  * @test
  */
 public function truncate()
 {
     $this->fixture->query('TRUNCATE item');
 }