Add a LIKE condition to your select query
@param String $field
@param String $content
@param String $condition
@return PhpBURN_Core
Params
$field
Model field that will receive LIKE statement
$content
The LIKE content statement. Ex. “A%” or “%Smith” or “%Jo%”
$condition (optional)
By default it have “AND” condition but you can change it to another one if you fill this optional field
Explanation
LIKE statement is a very handy tool for many reasons ( autocompletions, full-text searchs, etc… )
Let’s see it in action:
$user = new Users(); $user->like('first_name','A%'); $user->find(); while($user->fetch()) { print_r($user->toArray()); }
It will return all our Users that first_name begins with A, for example: Andy, Anderson, Acid, etc…
Other very handy way of use this is for FULL-TEXT search for example:
$user = new Users(); $user->like('first_name','%JO%'); $user->find(); while($user->fetch()) { print_r($user->toArray()); }
It will bring us all users with JO in any part of their fist_name such as Mojo, John, Mijoyo, etc….