예제 #1
0
 /**
  * @param string $statement
  * @param array $options
  * @return TestPDOStatement
  */
 public function prepare($statement, $options = array())
 {
     $statement = parent::prepare($statement, $options);
     return new TestPDOStatement($statement);
 }
예제 #2
0
 public function testTransactions()
 {
     $dsn = 'sqlite::memory:';
     $lazy = new LazyPDO($dsn, 'user', 'pass', array());
     $lazy->exec('CREATE TABLE my_test (id INT PRIMARY KEY)');
     // Successful case
     $lazy->beginTransaction();
     $insert = $lazy->prepare('INSERT INTO my_test VALUES (:id)');
     $insert->execute(array(':id' => 1));
     $lazy->commit();
     // Unsuccessful case
     $lazy->beginTransaction();
     $insert = $lazy->prepare('INSERT INTO my_test VALUES (:id)');
     $insert->execute(array(':id' => 2));
     $lazy->rollBack();
     $select = $lazy->prepare('SELECT * FROM my_test');
     $select->execute();
     $this->assertEquals(array(array('id' => 1)), $select->fetchAll(PDO::FETCH_ASSOC));
 }