Beispiel #1
0
 function tearDown()
 {
     parent::tearDown();
     $this->persistenceDriver = null;
     Entity::unsetDefaultPersistenceDriver();
 }
Beispiel #2
0
 /**
  * @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());
 }