public function testGetDeleteSQLOnNotAnnotatedEntity() { $this->notAnnotatedTest->setId(1); $sql = $this->notAnnotatedTableData->getDeleteSQL($this->notAnnotatedTest); $this->assertEqualsFixture($sql, __FUNCTION__); $this->runQuery($sql); }
/** * Deletes an entity from the database * @param $entityOrId * @return null|object */ public function delete($entityOrId) { $query = is_object($entityOrId) ? $this->table->getDeleteSQL($entityOrId) : $this->table->getDeleteByIdSQL($entityOrId); $this->runQuery($query); if (!mysqli_affected_rows($this->database->getMysqli()) > 0) { throw new \RuntimeException("Nothing was deleted, might be due to optimistic locking failure or simply that the entity no longer exists"); } }