Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

Save an Array on Mongo.

Hi, I'm recently was using the Phalcon Micro without problem, on my API I use Mongodb, when I need to save, update, find, etc I was using the Mongo PHP Extension without problem, right now I want to learn more I and decided to use Phalcon ODM, but right now I was unable to save an array to my mongo collection.

Here is my current simple code:

    //Unable to save data.
    $photo = array("url" => "http://xxx", "name" => "Nice", "catalog" => array("name" => "TC", "id" => 2 ));
    $photos = new photos; 
    $photos->save($photo);
    // Can save data using this pattern
    $photos = new photos; 
    $photos->url = "http//xxx";
    $photos->name = "Nice";
    $photos->catalog = array("name" => "TC", "id" => 2 );
    $photos->save();

I'm missing something because using the php mongo extension can save the array without problem.

Thank you in advance!



99.6k
Accepted
answer

Yea. Mongo is just diffrent than model. Doesn't have option to save like this.



661

Yea. Mongo is just diffrent than model. Doesn't have option to save like this.

Thank you for your response, so, is not another way to accomplish this? And what about the performance, what do you recommend use Phalcon ODM or just continue using the PHP Mongo Extesion.

Best Regards.

edited Jan '17

But phalcon needs php mongo extension anyway so i don't understand your question. Phalcon ODM just provides classes with methods to work with mongo easier and simpler. You can always create NFR/PR for mongo on github.



661

Now I get it, I thought Phalcon could do the job without the mongo extension, Now this comments clarified my doubts about that. Thank you like always. Have a nice day. Best Regards.

But phalcon needs php mongo extension anyway so i don't understand your question. Phalcon ODM just provides classes with methods to work with mongo easier and simpler. You can always create NFR/PR for mongo on github.