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

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

WBOY
Release: 2016-06-06 20:45:08
Original
1001 people have browsed it

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>
Copy after login
Copy after login

执行后返回:

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

我在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>
Copy after login
Copy after login

执行后返回:

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

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

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

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template