1

为了更好地分配分片 Mongo GridFs 中的文件,我想创建自己的 files_id。此处描述了如何在 Java 中完成此操作:

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

但是如何在 PHP 中做到这一点?我在 API 文档中找不到任何提示,我使用 storeBytes 来保存文件:

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

4

1 回答 1

1

您应该可以使用“_id”键在“$extra”参数中设置它,例如:

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

干杯,德里克

于 2012-01-23T13:07:57.923 回答