Ejemplo n.º 1
0
Archivo: Row.php Proyecto: smasty/neevo
 /**
  * Deletes corresponding database row if available.
  * @throws NeevoException
  * @return int Number of affected rows.
  */
 public function delete()
 {
     if ($this->frozen) {
         throw new NeevoException('Delete disabled - cannot get primary key or table.');
     }
     return Statement::createDelete($this->connection, $this->table)->where($this->primary, $this->data[$this->primary])->limit(1)->affectedRows();
 }
Ejemplo n.º 2
0
 private function createDelete($table)
 {
     return Statement::createDelete($this->connection, $table);
 }
Ejemplo n.º 3
0
 public function testResetState()
 {
     $stmt = Statement::createDelete($this->connection, 'table');
     $stmt->affectedRows();
     $res = new ReflectionMethod($stmt, 'resetState');
     $res->setAccessible(true);
     $res->invoke($stmt);
     $aff = new ReflectionProperty('Neevo\\Statement', 'affectedRows');
     $aff->setAccessible(true);
     $this->assertNull($aff->getValue($stmt));
 }
Ejemplo n.º 4
0
 /**
  * DELETE statement factory.
  * @param string $table
  * @return Statement fluent interface
  */
 public function delete($table)
 {
     $statement = Statement::createDelete($this->connection, $table);
     foreach ($this->observers as $observer) {
         $statement->attachObserver($observer, $this->observers->getInfo());
     }
     return $statement;
 }