Hi All,
Below are my setup on my local:
Service // Simple database connection to localhost
$di->set('mongo', function () { $mongo = new MongoClient(); return $mongo->selectDB("store"); }, true);
$di->set('collectionManager', function(){ return new Phalcon\Mvc\Collection\Manager(); }, true);
Model
class Robots extends \Phalcon\Mvc\Collection { public $name; public $year; }
Controller
class RobotsController extends ControllerBase
{
public function initialize()
{
$this->tag->setTitle('Data from MongoDb');
parent::initialize();
}
public function indexAction()
{
$return = array();
//with error of class robots not found
$result = Robots::find();
//below works
$result = $this->mongo->robots->find();
foreach ($result as $way){
$return = $way;
print_r($return);
}
return $return;
}
If i use $robots = new Robots(); the error also occur. Please help me on which part am i doing wrong.
Thank you in advanced