Hi,
I m trying to fire raw sql quueries using this article https://docs.phalcon.io/en/latest/reference/phql.html#using-raw-sql
$where = 'iterations_id In (SELECT max(iterations_id) 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(iterations_id) from ProjectsIterationTeams where project_id=49681) ', when parsing: SELECT [ProjectsIterationTeams].* FROM [ProjectsIterationTeams] WHERE iterations_id In (SELECT max(iterations_id) 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 iterations_id In
(select max(iterations_id) from projects_iterationteams where project_id=49681)';
$result = $this->modelsManager->executeQuery($phql);
var_dump($result);
And getting Exception :-
object(Phalcon\Mvc\Model\Exception)[115]
protected 'message' => string 'Scanning error before 'projects_iterati...' when parsing: select * FROM projects_iterationteams
WHERE iterations_id In
(select max(iterations_id) from projects_iterationteams 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