使用PHP在mongo GridFs中创建自己的files_id [英] create own files_id in mongo GridFs using PHP

查看:169
本文介绍了使用PHP在mongo GridFs中创建自己的files_id的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了在分片的Mongo GridF中更好地分发文件,我想创建自己的files_id.在Java中如何完成此操作的说明如下:

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

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

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

推荐答案

您应该能够使用"_id"键在"$ extra"自变量中进行设置,例如:

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"));

欢呼声, 德里克

这篇关于使用PHP在mongo GridFs中创建自己的files_id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆