Example #1
0
 /**
  * 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");
     }
 }