DataObjects: joinAdd problem

From: Date: Fri, 21 Jan 2005 13:38:40 +0000
Subject: DataObjects: joinAdd problem
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-17081@lists.php.net to get a copy of this message
Hi, i'm coding a search page with DB_DO and I have a problem. My tables are: Noticia: (id, titulo, ...); Tema: (id, ...); Not_Tema: (idn,idt); and my .links.ini: [Not_Tema] idn = Noticia:id idt = Tema:id when I search from within Noticia class: $this->selectAdd('Noticia.id,titulo'); $this->orderBy('titulo'); // search Noticias with a word within field "titulo": if ($palabra!=''){ $this->whereAdd("(titulo LIKE '%".$palabra."%')"); } // but only these ones that have a pair (idn,$v) in Not_Temas: if (!empty($temas)) { foreach ($temas as $v) { $nt = new DataObjects_Not_Tema; $nt->idt = $v; $this->joinAdd($nt,""); } } With only one value $v on pairs, this works, but how can I make that works with more $v? This code generate ($v=3,$v=4): (DBDO error) WHERE (titulo LIKE '%Salvador%') AND Not_Not_Tema.idn=Not_Noticia.id AND Not_Not_Tema.idt = 3 AND Not_Not_Tema.idn=Not_Noticia.id AND Not_Not_Tema.idt = 4 while I expect: WHERE (titulo LIKE '%Salvador%') AND (Not_Not_Tema.idn=Not_Noticia.id AND Not_Not_Tema.idt = 3 OR Not_Not_Tema.idn=Not_Noticia.id AND Not_Not_Tema.idt = 4) Can I do this with joinAdd? If not, how can I do? Only with plain sql? Thanks in advance for your help. Toni.

« previous php.pear.general (#17081) next »