We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

PHQL and binding parameters

I am quite new to phalcon and I finally started development, but obviously I kind of hit a wall (something that I expect will happen more often). A need to execute a little complex query, so I started experimenting with PHQL. Unfortunately I already am stuck. The query I will quote is not the one that I am trying to execute, but it seems to me that the problem is the same:

$strsql = "SELECT fldName FROM Field WHERE fldPublish = 1 AND fldSource = :name:";
$query = $this->modelsManager->createQuery($strsql);
$name = $query->execute($strsql, array(
            'name'  => 'indexController'
        ));

The query works when I do not bind parameters. When I am trying the above code, I get the following error:

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':name' at line 1


98.9k

What version are you using?



9.8k

It's 1.2.6. But now it seems to be working...This is very confusing. I did a lot of changes to my little project and maybe I had something missing what was overlooked by accident. I do have a backup, I will try to figure it out. I will post the solution if I manage to find it.