0
votes

I want to create a search function on my website, and I don't want to use a plugin for this thing, because it's very simple, but I can't solve this problem:

I give the keyword to the model which creates a query, but I couldn't figure out how to put joker characters in this query.

I'm using Propel

Dennis

1

1 Answers

0
votes

The filterByXXX() query functions will use LIKE when your query contains wildcards:

$books = BookQuery::create()
  ->filterByTitle('War%')
  ->find();
// example Query generated for a MySQL database
$query = 'SELECT book.* from `book` WHERE book.TITLE LIKE :p1'; // :p1 => 'War%'

Remember, the wildcards you can use in SQL are _ for exactly one and % for zero or more characters. So not ? or *.