Exemplo n.º 1
0
 function testPessimisticLockFail()
 {
     $this->table->attach(new Table\PessimisticLock());
     $txn = $this->table->getConnection()->startTransaction();
     $row = $this->table->find(null, null, 1)->current();
     $row->data = "foo";
     executeInConcurrentTransaction($this->table->getQueryExecutor(), "UPDATE {$this->table->getName()} SET data='bar' WHERE id=\$1", array($row->id->get()));
     $this->setExpectedException("\\UnexpectedValueException", "Row has already been modified");
     $row->update();
     $txn->commit();
 }
Exemplo n.º 2
0
 /**
  * Delete all rows of this rowset
  * @param mixed $txn
  * @return \pq\Gateway\Rowset
  * @throws \Exception
  */
 function delete($txn = true)
 {
     if ($txn && !$txn instanceof pq\Transaction) {
         $txn = $this->table->getConnection()->startTransaction();
     }
     try {
         foreach ($this->rows as $row) {
             $row->delete();
         }
     } catch (\Exception $e) {
         if ($txn) {
             $txn->rollback();
         }
         throw $e;
     }
     if ($txn) {
         $txn->commit();
     }
     return $this;
 }