FAQ
hey ,i am new to mongoDB and i have to work on mongoDB through the PHP
scripts ..can anybody provide me with a sample database for eg.the database
of a project like SURVEY .as i am not getting how to work on mongo through
PHP .just to elaborate what i mean i am giving a sample along.


<?php
$document = array(
"_id" => "derickr",
"name" => "Derick Rethans",
"articles" => array(
array(
"title" => "Profiling PHP Applications",
"url" => "http://derickrethans.nl/talks/profiling-phptourlille11.pdf",
),
array(
"title" => "Xdebug",
"url" => "http://derickrethans.nl/talks/xdebug-phpbcn11.pdf",
)
)
);
$m = new Mongo();
var_dump( $m->demo->articles->insert( $document ) );
?>

--
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongodb-user@googlegroups.com
To unsubscribe from this group, send email to
mongodb-user+unsubscribe@googlegroups.com
See also the IRC channel -- freenode.net#mongodb

---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Arthur Cláudio Almeida Pereira at Aug 17, 2013 at 2:13 pm
    Hi Nancy.

       What is the var_dump output ? Your script looks fine to me.

    cheers,


    2013/8/17 nancy gupta <nancy.aries@gmail.com>
    hey ,i am new to mongoDB and i have to work on mongoDB through the PHP
    scripts ..can anybody provide me with a sample database for eg.the database
    of a project like SURVEY .as i am not getting how to work on mongo through
    PHP .just to elaborate what i mean i am giving a sample along.


    <?php
    $document = array(
    "_id" => "derickr",
    "name" => "Derick Rethans",
    "articles" => array(
    array(
    "title" => "Profiling PHP Applications",
    "url" => "http://derickrethans.nl/talks/profiling-phptourlille11.pdf",
    ),
    array(
    "title" => "Xdebug",
    "url" => "http://derickrethans.nl/talks/xdebug-phpbcn11.pdf",
    )
    )
    );
    $m = new Mongo();
    var_dump( $m->demo->articles->insert( $document ) );
    ?>

    --
    --
    You received this message because you are subscribed to the Google
    Groups "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com
    To unsubscribe from this group, send email to
    mongodb-user+unsubscribe@googlegroups.com
    See also the IRC channel -- freenode.net#mongodb

    ---
    You received this message because you are subscribed to the Google Groups
    "mongodb-user" group.
    To unsubscribe from this group and stop receiving emails from it, send an
    email to mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    --
    You received this message because you are subscribed to the Google
    Groups "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com
    To unsubscribe from this group, send email to
    mongodb-user+unsubscribe@googlegroups.com
    See also the IRC channel -- freenode.net#mongodb

    ---
    You received this message because you are subscribed to the Google Groups "mongodb-user" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Benjamin Neu at Aug 18, 2013 at 1:51 pm
    As far as I know its not Mongo its MongoClient

      <?php

    $m = new MongoClient(); // connect
    $db = $m->foo; // get the database named "foo"

    ?>

    Have you installed the pear extension nodule mongo for PHP ?

    Insert:
    $m = new MongoClient();
    $collection = $m->selectCollection('test', 'phpmanual');

    // If an array literal is used, there is no way to access the generated _id
    $collection->insert(array('x' => 1));


    --
    --
    You received this message because you are subscribed to the Google
    Groups "mongodb-user" group.
    To post to this group, send email to mongodb-user@googlegroups.com
    To unsubscribe from this group, send email to
    mongodb-user+unsubscribe@googlegroups.com
    See also the IRC channel -- freenode.net#mongodb

    ---
    You received this message because you are subscribed to the Google Groups "mongodb-user" group.
    To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupmongodb-user @
categoriesmongodb
postedAug 17, '13 at 1:16p
activeAug 18, '13 at 1:51p
posts3
users3
websitemongodb.org
irc#mongodb

People

Translate

site design / logo © 2022 Grokbase