fkooman\RemoteStorage\MetadataStorage::deleteNode PHP Method

deleteNode() public method

public deleteNode ( Path $p )
$p Path
    public function deleteNode(Path $p)
    {
        $stmt = $this->db->prepare(sprintf('DELETE FROM %s WHERE path = :path', $this->prefix . 'md'));
        $stmt->bindValue(':path', $p->getPath(), PDO::PARAM_STR);
        $stmt->execute();
        if (1 !== $stmt->rowCount()) {
            throw new MetadataStorageException('unable to delete node');
        }
    }

Usage Example

 public function deleteDocument(Path $p, array $ifMatch = null)
 {
     if (null !== $ifMatch && !in_array($this->md->getVersion($p), $ifMatch)) {
         throw new PreconditionFailedException('version mismatch');
     }
     $deletedEntities = $this->d->deleteDocument($p);
     foreach ($deletedEntities as $d) {
         $this->md->deleteNode(new Path($d));
     }
     // increment the version from the folder containing the last deleted
     // folder and up to the user root, we cannot conveniently do this from
     // the MetadataStorage class :(
     foreach ($p->getFolderTreeToUserRoot() as $i) {
         if (null !== $this->md->getVersion(new Path($i))) {
             $this->md->updateFolder(new Path($i));
         }
     }
 }