Re: DataObjects: joinAdd problem

From: Date: Tue, 25 Jan 2005 06:31:21 +0000
Subject: Re: DataObjects: joinAdd problem
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-17142@lists.php.net to get a copy of this message
Try CVS, with debugging on, I've added messages indicating which ini + links.ini is loaded. Regards Alan Toni wrote:
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 (#17142) next »