create own files_id in mongo GridFs using PHP

限于喜欢 提交于 2019-12-11 08:26:38

问题


for a better distribution of files in a sharded Mongo GridFs I'd like to create my own files_id. How this can be done in Java is described here:

http://groups.google.com/group/mongodb-user/msg/524bae1602770587

But how to do this in PHP? I could find no hint in the API documentation, I use storeBytes for saving the files:

http://www.php.net/manual/en/mongogridfs.storebytes.php


回答1:


You should be able to just set this in the "$extra" argument with the "_id" key, something like:

$m = new Mongo;
$db = $m->phpunit;
$grid = $db->GetGridFS();
$grid->storeBytes("testing", array("_id" => "MYID", "filename" => "test.txt"));

cheers, Derick



来源:https://stackoverflow.com/questions/8907050/create-own-files-id-in-mongo-gridfs-using-php

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!