We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Mongo batchSize

Hello guys. I am new in phlacon and mongodb. I am doing

$mongo = $this->di->get('MongoDb'); $logs = $mongo->find(); but i am taking an error PHP Fatal error: Call to undefined method MongoDB::find()

I want to know how i can use mongodb connection without ODM and also if i can use the batchSize(). Because i can't see that ODM has inside it.

Thank you

edited Mar '15

Ok this not work that way, you should create a phalcon collection as Model. this create a mongo cursor

namespace Example\Collections;

class Robots extends \Phalcon\Mvc\Collection
{

        public function getSource()
        {
                //Mongo collection
                return "robots";
        }

}

last in your controller

$robots = Robots::find();

Yes i have created a phalcon model

<code> <?php use \Phalcon\Mvc\Collection as Collection;

class Events extends Collection {

public function initialize()
{
    $this->setConnectionService('MongoDB');
}

public function getSource()
{
    return "events";
}

}

</code>

and at controller i did it and it worked!!!! But it is not what i am asking. I want to use plain html for mongo queries and not phalcon's odm!