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

A bug? of PHQL with [like statement]

Not very sure about this problem, when I use the below code, it will always return nothing. Anyone knows? Thanks.

$rs=Student::find( array(
    "conditions" => "name like '%?1%'",
    "bind"       => array(1 => $query),
));


8.1k
Accepted
answer
edited Nov '14

Just you forgot PHP syntax :)

This construction should work

$name_like = '%bel%'
$rs=Student::find( array( "conditions" => "name like ?1", "bind" => array(1 => $name_like), ));


5.4k

Oh...It confuses about 3 hours!! Oleg, Big thanks!

Just you forgot PHP syntax :)

This construction should work

$name_like = '%bel%'
$rs=Student::find( array( "conditions" => "name like ?1", "bind" => array(1 => $name_like), ));