Solved thread

This post is marked as solved. If you think the information contained on this thread must be part of the official documentation, please contribute submitting a pull request to its repository.

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),
));


7.3k
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), ));


3.3k

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), ));