[英]create own files_id in mongo GridFs using PHP
for a better distribution of files in a sharded Mongo GridFs I'd like to create my own files_id. 为了在分片的Mongo GridF中更好地分发文件,我想创建自己的files_id。 How this can be done in Java is described here:
这里描述了如何在Java中完成此操作:
http://groups.google.com/group/mongodb-user/msg/524bae1602770587 http://groups.google.com/group/mongodb-user/msg/524bae1602770587
But how to do this in PHP? 但是如何在PHP中做到这一点? I could find no hint in the API documentation, I use storeBytes for saving the files:
我在API文档中找不到任何提示,我使用storeBytes保存文件:
http://www.php.net/manual/en/mongogridfs.storebytes.php http://www.php.net/manual/zh/mongogridfs.storebytes.php
You should be able to just set this in the "$extra" argument with the "_id" key, something like: 您应该可以使用“ _id”键在“ $ extra”参数中进行设置,例如:
$m = new Mongo; $db = $m->phpunit; $grid = $db->GetGridFS(); $grid->storeBytes("testing", array("_id" => "MYID", "filename" => "test.txt"));
cheers, Derick 干杯,德里克
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.