function tearDown() { parent::tearDown(); $this->persistenceDriver = null; Entity::unsetDefaultPersistenceDriver(); }
/** * @param Entity $entity * @return bool */ function delete(Entity $entity) { if (!$entity->getPK()) { throw new \LogicException("Cannot delete entity: PK is empty"); } $sql = "DELETE FROM {$entity->getSourceName()} " . " WHERE {$entity->getPKName()} = :{$entity->getPKName()}"; $stmt = $this->db->prepare($sql); $result = $stmt->execute([$entity->getPKName() => $entity->getPK()]); if (!$result) { throw new \RuntimeException("DELETE entity: DB query failed (PK: {$entity->getPK()})"); } return (bool) $stmt->rowCount(); }
/** * @param Entity $proto * @retrun \Zhandlersocket\Index */ protected function getIndex(Entity $proto) { return $this->zClient->getIndex($this->dbName, $proto->getSourceName(), "PRIMARY", $proto->getColumns()); }