Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Updating sharding document with ISODate in PHP
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Ardian P. Atmaja  
View profile  
 More options Sep 26 2012, 11:14 pm
From: "Ardian P. Atmaja" <ardm...@gmail.com>
Date: Thu, 27 Sep 2012 10:14:27 +0700
Local: Wed, Sep 26 2012 11:14 pm
Subject: Re: [mongodb-user] Re: Updating sharding document with ISODate in PHP

it's still not working, Gianfranco. it returns like '1970-01-01'. finally i
changed the 'saved_at' type to date('Y-m-d H:i:s') on save function so in
the collection shows '12-09-20 01-02-16', for example. the new update query
is:

*mongos> db.blog.update({'name':'myname','saved_at':'12-09-20 01-02-16',
{$set: {'comment':'its my first comment for sample.'}};*

On Thu, Sep 20, 2012 at 4:29 PM, Gianfranco <gianfra...@10gen.com> wrote:
> As I mentioned in line 21, when you output in php you'll need to convert
> the MongoDate to string with a format similar to:

> date <http://www.php.net/date>('Y-M-d h:i:s', $obj["saved_at"]->sec)

> On Thursday, September 20, 2012 12:29:41 AM UTC+1, Onyon wrote:

>> Thanks Gianfranco, but i still have a trouble in using ISODate value in
>> document which will updated.
>> How about $date in line 11 if i throw the saved_at value from a field in
>> another form? here's my form:

>> <form action="addcomment.php" method="post">
>>   <input name="name" value="<?php echo $blog['name']; ?>"/>
>>   <input name="saved_at" value="*<?php echo $blog['saved_at']; ?>*"/>
>>   <input type="submit" name="submit" value="Post"/>
>> </form>

>> its reads 0.29500000 1348043425 but ISODate in the shell like "saved_at":
>> ISODate("2012-09-19T08: 30: 25.295Z").
>> How i use its ISODate value to updating document?

>> Pada Rabu, 19 September 2012 23:57:16 UTC+7, Gianfranco menulis:

>>> Here's an example:

>>>    1. // Connect
>>>    2. $m = new Mongo();
>>>    3.
>>>    4. // Select a database
>>>    5. $db = $m->test;
>>>    6.
>>>    7. // Select a collection (analogous to a relational database's
>>>    table)
>>>    8. $collection = $db->blog;
>>>    9.
>>>    10. // Description of the objects to update.
>>>    11. $criteria = array <http://www.php.net/array>("name" => "**myname"
>>>    , "saved_at" => $date);
>>>    12.
>>>    13. // The object with which to update the matching records.
>>>    14. $newdata = array <http://www.php.net/array>('$set' => arr**ay<http://www.php.net/array>
>>>    ("comment" => "its my first comment for sample."));
>>>    15.
>>>    16. // Do the update
>>>    17. $collection->update($criteria,** $newdata);
>>>    18.
>>>    19. // Iterate through the results
>>>    20. foreach ($cursor as $obj) {
>>>    21.     echo $obj["name"] . " " . date <http://www.php.net/date>('Y-M-d
>>>    h:i:s', $obj["saved_at"]->sec)** . " " .  $obj["comment"] . "\n";
>>>    22. }

>>> And if you look in the shell you see an ISODate():

>>>    1. > db.cartoons.find()
>>>    2. { "_id": ObjectId("**5059f8443e20d65344000000"), "**name":
>>>    "myname", "comment": "i**ts my first comment for sample.", "saved_at"
>>>    : ISODate(**"20120919T02:47:44Z") }

>>> On Wednesday, September 19, 2012 2:05:38 PM UTC+1, Onyon wrote:

>>>> Hi, i have some sharding enable collection called blog with *name* and
>>>> *saved_at* (ISODate) for its shard keys. when updating comments that
>>>> embedding in its documents, ISODate need to be called and also name, for
>>>> its shard keys. in the shell, the command look like:

>>>> *mongos> db.blog.update({'name':'myname','saved_at':ISODate('2012-09-19T03:47:44.602 Z')},
>>>> {$set: {'comment':'its my first comment for sample.'}};*

>>>> my question is: How to implement it to PHP code?. i still confuse about
>>>> an ISODate issue in mongoDB - PHP. i've tried to searching it at Google but
>>>> not find the best result to solve that problem.
>>>> Thank you.

>>>  --
> 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 must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.