I would like to upgrade to php7 phalcon.
One issue that I have is that my Collections are hooked up to the old Mongo driver which is now deprecated and cannot be used in php7.
MongoDB driver (mongodb-1.1) is a backwards compatible vendor specific database extension (https://php.net/manual/en/set.mongodb.php) and my hope is that a minimal refactor in php 5.6.x will allow me to upgrade to php7.
So that my refactor is minimal I wouls like to use this Php library: https://github.com/mongodb/mongo-php-library whic is installed using composer:
composer require "mongodb/mongodb=^1.0.0"
Services using official wrapper class:
$di->set('mongo', function() use ($config) {
$mongo = new \MongoDB\Client();
return $mongo->selectDatabase($config->mongodb->dbname);
}, true);
$di->set('collectionManager', function() {
return new Phalcon\Mvc\Collection\Manager();
}, true);
So far I have only had to wrap my aggregate query in an array.
However I am having a problem with ::findFirst() in php 5.6 phalcon 3.0.1:
In my collection class::
$result = self::findFirst([
["item_id" => intval($item_id)]
])
The error I am getting is:
[10-Nov-2016 13:41:05 Europe/London] Call to undefined method MongoDB\Driver\Cursor::rewind()
#0 [internal function]: Phalcon\Mvc\Collection::_getResultset(Array, Object(Common\Models\ItemRatingStats), Object(MongoDB\Database), true)
#1 ...apps/common/models/ItemRatingStats.php(56): Phalcon\Mvc\Collection::findFirst(Array)
Could anyone help or comment.
I would like to use this vendor wrapper driver class as it offers backwards compatability to php7 from php5.6.x.
It comes recommended from MongoDB and is a favored Vendor Specific Database Extension.