Search code examples
phpmysqlormpropel

Propel ORM PHP LIKE * Sentence


I need some help in order to execute the next query. I searched the Propel ORM documentation and haven't found anything related to do a WHERE LIKE query and using "*" to found multiple results:

->where('Player.Name LIKE ?*', $filter)
->find();

Is there any way to make this query using Active Query?


Solution

  • Propel is built on top of PDO, so the above would still not be valid even when using PDO directly. So you don't use ? with other characters, instead you concatenate them into the variable, in your case $filter should contain your wild-card (i.e. % not *).

    So you'd first add it to $filter,

    e.g. $filter = '%' . $filter . '%';

    then the correct syntax would be:

    ->where('Player.Name LIKE ?', $filter)

    or do it on the fly:

    ->where('Player.Name LIKE ?', '%' . $filter . '%')