delete() public method

Chooses an appropriate storage and calls its {@see VersionPress\Storages\Storage::delete() delete()} method.
See also: Storage::delete()
public delete ( string $entityName, array $restriction )
$entityName string Entity type determines the storage used
$restriction array Restriction passed to the `VersionPress\Storages\Storage::delete()` method
Exemplo n.º 1
0
 function delete($table, $where)
 {
     if ($this->disabled) {
         return;
     }
     $entityInfo = $this->dbSchemaInfo->getEntityInfoByPrefixedTableName($table);
     if (!$entityInfo) {
         return;
     }
     $entityName = $entityInfo->entityName;
     if (!$entityInfo->usesGeneratedVpids) {
         $this->mirror->delete($entityName, $where);
         return;
     }
     $ids = $this->detectAllAffectedIds($entityName, $where, $where);
     foreach ($ids as $id) {
         $where['vp_id'] = $this->vpidRepository->getVpidForEntity($entityName, $id);
         if (!$where['vp_id']) {
             continue;
             // already deleted - deleting postmeta is sometimes called twice
         }
         if ($this->dbSchemaInfo->isChildEntity($entityName) && !isset($where["vp_{$entityInfo->parentReference}"])) {
             $where = $this->fillParentId($entityName, $where, $id);
         }
         $this->vpidRepository->deleteId($entityName, $id);
         $this->mirror->delete($entityName, $where);
     }
 }
 private function deleteReference($referenceDetails, $where)
 {
     $sourceEntity = $referenceDetails['source-entity'];
     $targetEntity = $referenceDetails['target-entity'];
     $sourceColumn = $referenceDetails['source-column'];
     $targetColumn = $referenceDetails['target-column'];
     $reference = ["vp_{$sourceEntity}" => $this->vpidRepository->getVpidForEntity($sourceEntity, $where[$sourceColumn]), "vp_{$targetEntity}" => $this->vpidRepository->getVpidForEntity($targetEntity, $where[$targetColumn])];
     $this->mirror->delete($referenceDetails['junction-table'], $reference);
 }