/** * 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(); }
private function createDelete($table) { return Statement::createDelete($this->connection, $table); }
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)); }
/** * 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; }