We are moving our forum in GitHub Discussions. For questions about Phalcon v3/v4 you can visit here and for Phalcon v5 here.

Binding parameters: String placeholders not working?

I've been trying to figure out what i've been doing wrong, but I guess that string placeholders are just broken.


This doesn't seem to work for me:

$user = \user\User::findFirst(['username = :username', ['username' => 'testuser']]);

I get the following error:

Syntax error, unexpected token COLON, near to 'username', when parsing: SELECT [user\User].* FROM [user\User] WHERE username = :username (64)

Numberic place holders do seem to work for me.

$user = \user\User::findFirst(['username = ?1', [1 => 'testuser']]);

Can anyone confirm?


$user = \user\User::findFirst(["username = :username", ["username" => "testuser"]]);

isn't the same as

$user = \user\User::findFirst(["username = :username:", ["username" => "testuser"]]);

(at least that's what I see). Also, maybe it's more clear with:

$conditions = "username = :username:";
$binds = array(
    "username" => "testuser"
$something = Something::findFirst(

And if you don't get it, you forgot to close the bind parameter with :.

Ah, my bad. I'm coming from a different framework and did not expect the trailing colon. Somehow I looked over it. Thanks RompePC.