本文整理汇总了PHP中MongoDB::getGridFS方法的典型用法代码示例。如果您正苦于以下问题:PHP MongoDB::getGridFS方法的具体用法?PHP MongoDB::getGridFS怎么用?PHP MongoDB::getGridFS使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MongoDB
的用法示例。
在下文中一共展示了MongoDB::getGridFS方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetGridFS
public function testGetGridFS()
{
if (preg_match("/5\\.1\\../", phpversion())) {
$this->markTestSkipped("No implicit __toString in 5.1");
return;
}
$grid = $this->object->getGridFS();
$this->assertTrue($grid instanceof MongoGridFS);
$this->assertTrue($grid instanceof MongoCollection);
$this->assertEquals((string) $grid, "phpunit.fs.files");
$this->assertEquals((string) $grid->chunks, "phpunit.fs.chunks");
$grid = $this->object->getGridFS("foo");
$this->assertEquals((string) $grid, "phpunit.foo.files");
$this->assertEquals((string) $grid->chunks, "phpunit.foo.chunks");
$grid = $this->object->getGridFS("foo", "bar");
$this->assertEquals((string) $grid, "phpunit.foo.files");
$this->assertEquals((string) $grid->chunks, "phpunit.foo.chunks");
}
示例2: gridFS
public function gridFS($arg1 = NULL, $arg2 = NULL)
{
$this->_connected or $this->connect();
if (!isset($arg1)) {
$arg1 = isset($this->_config['gridFS']['arg1']) ? $this->_config['gridFS']['arg1'] : 'fs';
}
if (!isset($arg2) && isset($this->_config['gridFS']['arg2'])) {
$arg2 = $this->_config['gridFS']['arg2'];
}
return $this->_db->getGridFS($arg1, $arg2);
}
示例3: saveFile
/**
* Saves a file to MongoDB
*
* @param string $filePath
* @param array $oldReference
* @return mixed The id of the stored file
*/
public function saveFile($filePath, $oldReference = null)
{
$id = null;
if (file_exists($filePath)) {
if (!empty($oldReference)) {
$this->db->getGridFS()->remove(array('_id' => $oldReference), true); //remove existing file
}
$id = $this->db->getGridFS()->storeFile($filePath);
} else {
throw new \InvalidArgumentException("The file $filePath does not exist");
}
return $id;
}
示例4: doGetGridFS
/**
* Return a new GridFS instance.
*
* @see Database::getGridFS()
* @param string $prefix
* @return GridFS
*/
protected function doGetGridFS($prefix)
{
$mongoGridFS = $this->mongoDB->getGridFS($prefix);
return new GridFS($this, $mongoGridFS, $this->eventManager);
}