Home >Backend Development >PHP Tutorial >MongoDB插入数据后返回信息代码释义

MongoDB插入数据后返回信息代码释义

WBOY
WBOYOriginal
2016-06-06 20:45:081003browse

PHP程序,附代码:

<code class="lang-php">$mongo = new MongoClient();
$db = $mongo->btss;
$hashs = $mongo->db->hash;
$hash = $hashs->insert(array('hash' => $msg));
var_dump($hash);
</code>

执行后返回:

<code class="lang-php">array(4) { ["ok"]=> float(1) ["n"]=> int(0) ["err"]=> NULL ["errmsg"]=> NULL }
</code>

我在mongo中检查没有数据,但是这个错误又没有有用的信息,特此来请教下(GG也没有)

回复内容:

PHP程序,附代码:

<code class="lang-php">$mongo = new MongoClient();
$db = $mongo->btss;
$hashs = $mongo->db->hash;
$hash = $hashs->insert(array('hash' => $msg));
var_dump($hash);
</code>

执行后返回:

<code class="lang-php">array(4) { ["ok"]=> float(1) ["n"]=> int(0) ["err"]=> NULL ["errmsg"]=> NULL }
</code>

我在mongo中检查没有数据,但是这个错误又没有有用的信息,特此来请教下(GG也没有)

因为你把数据添加到了db这个数据库里,而不是btss

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn