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

Phalcon 3.0 / PHP 7 / Mongo ODM

Hi, I t'm tryin to upgrade my projects under Phalcon 3.0 and PHP 7. MongoDb Client has been update and Phalcon 3.0 doesn't support the new \MongoDB\Driver\Manager.

It is there any solutions or MAJ planned for fix this problem ? Thanks :)



1.2k
edited Aug '16

Hello Andy, thanks for your quick response ! I tried this solution. I correctly load the library and its namespace but when i try a simple request like: Musics::find(), I've this message:

The argument is not initialized or iterable()<br><pre>#0 [internal function]: Phalcon\Mvc\Collection::cloneResult(Object(Musics), Object(Phalcon\Db\Adapter\MongoDB\Model\BSONDocument))
#1 [internal function]: Phalcon\Mvc\Collection::_getResultset(Array, Object(Musics), Object(Phalcon\Db\Adapter\MongoDB\Database), false)
#2 /var/www/adminapi/app.php(11): Phalcon\Mvc\Collection::find()
#3 [internal function]: Closure->{closure}()
#4 /var/www/adminapi/public/index.php(38): Phalcon\Mvc\Micro->handle()
#5 {main}

My model:

use Phalcon\Mvc\Collection;

use Phalcon\Mvc\Model\Validator\PresenceOf;
use Phalcon\Mvc\Model\Validator\Numericality;
use Phalcon\Mvc\Model\Validator\StringLength;

class Musics extends Collection
{

    public function getSource()
    {
        return 'musics';
    }
}

Any idea ?

Thanks

Hi, perhaps it is mongoId, now is Object id you should be create an adapter for treat MongoId to ObjectId