Beispiel #1
0
 public function testAffectedRowsError()
 {
     $this->connection->getDriver()->setError('affected-rows');
     $stmt = Statement::createDelete($this->connection, 'table');
     $stmt->run();
     $r = new ReflectionProperty($stmt, 'affectedRows');
     $r->setAccessible(true);
     $this->assertFalse($r->getValue($stmt));
     $this->setExpectedException('Neevo\\DriverException', 'Affected rows are not supported by this driver.');
     $stmt->affectedRows();
 }
Beispiel #2
0
 public function testCloseConnection()
 {
     $this->instance->attachObserver($o = new DummyObserver(), DummyObserver::DISCONNECT);
     $this->instance->__destruct();
     $this->assertTrue($this->instance->getDriver()->isClosed());
     $this->assertTrue($o->isNotified());
 }
Beispiel #3
0
 /**
  * Returns the name of the PRIMARY KEY column.
  * @return string|null
  */
 public function getPrimaryKey()
 {
     $table = $this->getTable();
     if (!$table) {
         return null;
     }
     $key = null;
     $cached = $this->connection->getCache()->fetch($table . '_primaryKey');
     if ($cached === null) {
         try {
             $key = $this->connection->getDriver()->getPrimaryKey($table, isset($this->resultSet) ? $this->resultSet : null);
         } catch (NeevoException $e) {
             return null;
         }
         $this->connection->getCache()->store($table . '_primaryKey', $key);
         return $key === '' ? null : $key;
     }
     return $cached === '' ? null : $cached;
 }
Beispiel #4
0
 /**
  * Rollbacks changes in a transaction.
  * @param string $savepoint
  * @return Manager fluent interface
  */
 public function rollback($savepoint = null)
 {
     $this->connection->getDriver()->rollback($savepoint);
     $this->notifyObservers(ObserverInterface::ROLLBACK);
     return $this;
 }