Mysql Query not working

this query not working in my phalcon project but it execute in mysql very well.

$query="SELECT distinct ats.statusid, astat.value FROM ActivityTypeStatus ats, ActivityStatus astat where ats.typeid IN(1,4,2) and ats.statusid = astat.statusid"; $activitystatus = $this->modelsManager->createQuery($query); $rows = $activitystatus->execute();

edited Mar '14

"modelsManager->createQuery" accepts only PHQL http://docs.phalconphp.com/en/latest/reference/phql.html

But PHQL has some restrictions for now... try to use "AS" statement in "FROM ActivityTypeStatus AS ats, ActivityStatus AS astat".

And also it is possible some problems with DISTINCT https://github.com/phalcon/cphalcon/issues/1631 (with Postgresal).

edited Mar '14

If you want to use PDO you can just call get your DB intsance from your bootstrap where you set it in the DI:0

    $di->set('db', function() {
          $database = new Phalcon\Db\Adapter\Pdo\Mysql([ /** Your Config Here **/]);
          return $database;
    });

To get the instance from any location in Phalcon use:

    $di = Phalcon\DI::getDefault();
    $db = $di->get('db');

Then you can call:

    $result = $db->execute("Your string");