<i id='emVaj'><tr id='emVaj'><dt id='emVaj'><q id='emVaj'><span id='emVaj'><b id='emVaj'><form id='emVaj'><ins id='emVaj'></ins><ul id='emVaj'></ul><sub id='emVaj'></sub></form><legend id='emVaj'></legend><bdo id='emVaj'><pre id='emVaj'><center id='emVaj'></center></pre></bdo></b><th id='emVaj'></th></span></q></dt></tr></i><div id='emVaj'><tfoot id='emVaj'></tfoot><dl id='emVaj'><fieldset id='emVaj'></fieldset></dl></div>
<legend id='emVaj'><style id='emVaj'><dir id='emVaj'><q id='emVaj'></q></dir></style></legend>
  • <tfoot id='emVaj'></tfoot>

      <small id='emVaj'></small><noframes id='emVaj'>

        <bdo id='emVaj'></bdo><ul id='emVaj'></ul>

        PHP中的MongoDB - 如何将项目插入集合中的数组?

        MongoDB in PHP - How do I insert items into an array in a collection?(PHP中的MongoDB - 如何将项目插入集合中的数组?)

      1. <small id='0ncAA'></small><noframes id='0ncAA'>

          <tbody id='0ncAA'></tbody>

        • <legend id='0ncAA'><style id='0ncAA'><dir id='0ncAA'><q id='0ncAA'></q></dir></style></legend>

            • <tfoot id='0ncAA'></tfoot>
              <i id='0ncAA'><tr id='0ncAA'><dt id='0ncAA'><q id='0ncAA'><span id='0ncAA'><b id='0ncAA'><form id='0ncAA'><ins id='0ncAA'></ins><ul id='0ncAA'></ul><sub id='0ncAA'></sub></form><legend id='0ncAA'></legend><bdo id='0ncAA'><pre id='0ncAA'><center id='0ncAA'></center></pre></bdo></b><th id='0ncAA'></th></span></q></dt></tr></i><div id='0ncAA'><tfoot id='0ncAA'></tfoot><dl id='0ncAA'><fieldset id='0ncAA'></fieldset></dl></div>
                • <bdo id='0ncAA'></bdo><ul id='0ncAA'></ul>
                • 本文介绍了PHP中的MongoDB - 如何将项目插入集合中的数组?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  这一定很简单,但我似乎无法弄清楚...假设我有一个集合 users,这是集合中的第一项:

                  This has to be easy, but i can't seem to figure it out... Let say i had a collection users and this is the first item in the collection:

                  { 
                      "_id" : ObjectId("4d8653c027d02a6437bc89ca"), 
                      "name" : "Oscar Godson", 
                      "email" : "oscargodson@xxx.com", 
                      "password" : "xxxxxx", 
                      "tasks" : [
                      {
                          "task" : "pick up stuff",
                          "comment" : "the one stuff over there"
                      },
                      {
                          "task" : "do more stuff",
                          "comment" : "lots and lots of stuff"
                      }
                  ] }
                  

                  然后我将如何使用 MongoDB 的 PHP 驱动程序将另一个任务"添加到集合中此项的任务"数组中

                  How with the PHP driver for MongoDB would I then go and add another "task" to the "tasks" array in this item in a collection

                  推荐答案

                  使用Mongo的$push操作:

                  Use Mongo's $push operation:

                  $new_task = array(
                    "task" => "do even more stuff",
                    "comment" => "this is the new task added"
                  );
                  $collection->update(
                    array("_id" => ObjectId("4d8653c027d02a6437bc89ca")), 
                    array('$push' => array("tasks" => $new_task))
                  );
                  

                  这篇关于PHP中的MongoDB - 如何将项目插入集合中的数组?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  DeepL的翻译效果还是很强大的,如果我们要用php实现DeepL翻译调用,该怎么办呢?以下是代码示例,希望能够帮到需要的朋友。 在这里需要注意,这个DeepL的账户和api申请比较难,不支持中国大陆申请,需要拥有香港或者海外信用卡才行,没账号的话,目前某宝可以
                  PHP通过phpspreadsheet导入Excel日期,导入系统后,全部变为了4开头的几位数字,这是为什么呢?原因很简单,将Excel的时间设置问文本,我们就能看到该日期本来的数值,上图对应的数值为: 要怎么解决呢?进行数据转换就行,这里可以封装方法,或者用第三方的
                  mediatemple - can#39;t send email using codeigniter(mediatemple - 无法使用 codeigniter 发送电子邮件)
                  Laravel Gmail Configuration Error(Laravel Gmail 配置错误)
                  Problem with using PHPMailer for SMTP(将 PHPMailer 用于 SMTP 的问题)
                  Issue on how to setup SMTP using PHPMailer in GoDaddy server(关于如何在 GoDaddy 服务器中使用 PHPMailer 设置 SMTP 的问题)

                        <tbody id='iLItn'></tbody>
                    • <legend id='iLItn'><style id='iLItn'><dir id='iLItn'><q id='iLItn'></q></dir></style></legend>

                      <tfoot id='iLItn'></tfoot>

                      1. <small id='iLItn'></small><noframes id='iLItn'>

                          <bdo id='iLItn'></bdo><ul id='iLItn'></ul>

                            <i id='iLItn'><tr id='iLItn'><dt id='iLItn'><q id='iLItn'><span id='iLItn'><b id='iLItn'><form id='iLItn'><ins id='iLItn'></ins><ul id='iLItn'></ul><sub id='iLItn'></sub></form><legend id='iLItn'></legend><bdo id='iLItn'><pre id='iLItn'><center id='iLItn'></center></pre></bdo></b><th id='iLItn'></th></span></q></dt></tr></i><div id='iLItn'><tfoot id='iLItn'></tfoot><dl id='iLItn'><fieldset id='iLItn'></fieldset></dl></div>