开发者

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();
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜