Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
'like' keyword
  • Hi, I'm trying to create a simple search function using the following code:
    $characters = Model_Character::find()->where('character_name', 'like', $keyword)->order_by('character_name', 'asc')->get();
    

    The 'like' only works if I enter a full name, but not when entering a part of the name. Any ideas why? Also is there a way to debug the query only?
    I tried doing
    Debug::dump($characters);
    

    but as expected it just gives me the result of the query in array form.
  • You have to tell SQL on which site you allow additional characters.
    ->where('field', 'like', '%allow left')
    ->where('field', 'like', 'allow right%')
    ->where('field', 'like', '%allow on both')
    

    More info: http://dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html#operator_like
  • Ooh totally forgot, I just looked at one of your examples and thought it would be implemented thanks, works

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion