• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Requete with several like and where

French :
je souhaite réaliser une requête de recherche qui va rechercher un post en filtrant sur une catégorie sélection avant.
La recherche se fera sur le nom et le content.
Voici ce que je souhaite obtenir :
English :
I want to make a search query that will search by filtering a post on a category selection before.
The research will be on name and content.
Here's what I want to:

FROM posts
WHERE posts.categoryid  =  '15'
AND  namepost  LIKE '%là%'
OR  posts.categoryid  =  '15'
AND content  LIKE '%là%'
J'ai essayer avec active record :
$this->db->like('namepost', $champsSerach);
$this->db->or_like('content', $champsSerach);
Mais j'obtiens :
FROM posts
WHERE posts.categoryid  =  '20'
AND posts.categoryid  =  '20'
AND  namepost  LIKE '%la%'
OR  content  LIKE '%la%'
A need your help please because i try lots things with where, or_where, etc.

[eluser]Rodrigo Alexandre[/eluser]

$this->db->where("(a.field LIKE '%$result%' OR b.field LIKE '%$result%')");
$this->db->where('c.field = '%$result%'');

thx for () because I did not know you can make :
where condition = x and (item1 like %xxx% or item2 like %xxx%)
I did as :
where condition = x and item1 like %xxx% or condition = x and item2 like %xxx%

more complexe and repetition.
so thx lots

There will be a way to natively do this with active record on the next release.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.