delete() public method

Delete a file from the database
public delete ( mixed $id ) : boolean
$id mixed _id of the file to remove
return boolean Returns true if the remove was successfully sent to the database.
コード例 #1
0
 /**
  * delete.
  */
 public function delete($id)
 {
     $this->time->start();
     $return = parent::delete($id);
     $time = $this->time->stop();
     $this->log(array('type' => 'delete', 'id' => $id, 'time' => $time));
     return $return;
 }
コード例 #2
0
 /**
  * Remove file
  *
  * @param  string  $path  file path
  * @return bool
  **/
 protected function _unlink($path)
 {
     $file = $this->getFile($path);
     if (!$file) {
         return false;
     }
     return $this->db->delete($file->file['_id']);
 }
コード例 #3
0
ファイル: Mongo.php プロジェクト: horde/horde
 /**
  */
 public function deleteFile($path, $name)
 {
     if ($orig = $this->_getFile($path, $name)) {
         $this->_checkQuotaDelete($path, $name);
         $this->_files->delete($orig->file['_id']);
     } else {
         throw new Horde_Vfs_Exception('Unable to delete VFS file.');
     }
 }
コード例 #4
0
ファイル: GridFS.php プロジェクト: saberyounis/Sonata-Project
 /**
  * @param \MongoGridFS $gridFs
  * @param \MongoGridFSFile $file
  */
 function it_should_rename_file($gridFs, $file)
 {
     $file->getBytes()->willReturn('some content');
     $file->getSize()->willReturn(12);
     $gridFs->findOne('otherFilename', array())->willReturn(null);
     $gridFs->findOne('filename', array())->shouldBeCalled()->willReturn($file);
     $gridFs->storeBytes('some content', array('date' => 1234, 'filename' => 'otherFilename'))->shouldBeCalled()->willReturn('someId');
     $fileToDelete = new \stdClass();
     $fileToDelete->file = array('_id' => 123);
     $gridFs->findOne('filename', array('_id'))->willReturn($fileToDelete);
     $gridFs->findOne(array('_id' => 'someId'))->willReturn($file);
     $gridFs->delete(123)->shouldBeCalled()->willReturn(true);
     $this->setMetadata('otherFilename', array('date' => 1234));
     $this->rename('filename', 'otherFilename')->shouldReturn(true);
 }