kohana 3 like statement
I want to know that how can I开发者_运维技巧 use like statement in Kohana 3 in both ways using ORM and Query builder
I am currently using sql statement like:
select * from tablename where keyword like "abc%"
I want to know its Query builder alternative and ORM alternative, I have tried:
->where('keyword','like',DB::expr("$keyword%"))
but didn't work
So what is better way
->where('keyword','like',"$keyword%")
I believe if you have multiple keywords, such as when exploding on a space, you can just use the array as the 3rd parameter for the where method.
$keywords = explode(' ', $_POST['keywords']);
DB::select()->from('table')->where('keywords', 'LIKE', $keywords)->execute();
精彩评论