mangala
mangala

Reputation: 143

IN clause in the kohana query builder

I have used the IN clause in the kohana query builders.

i have given the text in search

$var = "test link";

and i exploded with space.

$text = explode(' ', $var);

so my query is

$query = DB::select()->from( 'product' )->where( 'status', '=', 'A' )->and_where( 'title', 'IN', $text )->execute()->as_array();

I have the products in the titles with the test and link.

But the above query not giving the result.

Thanks in advance.

Upvotes: 0

Views: 202

Answers (1)

vaibhavmande
vaibhavmande

Reputation: 1111

If that column has "test link" value you wish it should be matched in the results then you need a query like this

$query = DB::select()->from( 'product' )->where( 'status', '=', 'A' );
$searchblock = explode(' ', $var);
foreach($searchblock as $block) {
    $query = $query->or_where('title', 'LIKE', "%$block%");
}
$result = $query->execute()->as_array();

Upvotes: 1

Related Questions