Models Managers Query Builder

Hi,

I m trying to fire raw sql quueries using this article http://docs.phalconphp.com/en/latest/reference/phql.html#using-raw-sql

$where = 'iterationsid In (SELECT max(iterationsid) from ProjectsIterationTeams where project_id=49681) ';

       $worklenz = $this->modelsManager->createBuilder()
                ->from(array('ProjectsIterationTeams'))
                ->where($where)
                //->limit($limit)
                ->getQuery()
                ->execute();

        var_dump($worklenz);

but I am getting the following error

protected 'message' => string 'Syntax error, unexpected token SELECT, near to ' max(iterationsid) from ProjectsIterationTeams where projectid=49681) ', when parsing: SELECT [ProjectsIterationTeams].* FROM [ProjectsIterationTeams] WHERE iterationsid In (SELECT max(iterationsid) from ProjectsIterationTeams where project_id=49681) (166)' (length=309) private 'string' (Exception) => string '' (length=0)

Even I have tried this

$phql = 'select * FROM projects_iterationteams WHERE iterationsid In (select max(iterationsid) from projectsiterationteams where projectid=49681)';

        $result = $this->modelsManager->executeQuery($phql);

        var_dump($result);

And getting Exception :-

object(Phalcon\Mvc\Model\Exception)[115] protected 'message' => string 'Scanning error before 'projectsiterati...' when parsing: select * FROM projects_iterationteams WHERE iterationsid In (select max(iterationsid) from projectsiterationteams where project_id=49681) (159)' (length=223)

How exactly we can fire subqueries , because I need a Model Object and if I m using Phql db query I am getting std object,which I don't require it.Anybody Please help...Thanks

Thanks for Reply...But I am using version 0.9 which is pretty old and I need some way to do Is their any way that we can use something in index.php as Dependency Injection. I am not sure might be "phalcon" do u have way.By which we can use subqueries and return Model Object.

Thanks