RE: [PEAR] Re: DataObjects "HAVING" ?
| From: | ThE PhP_KiD | Date: | Thu, 05 Jun 2003 06:20:07 +0000 |
| Subject: | RE: [PEAR] Re: DataObjects "HAVING" ? | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-5813@lists.php.net to get a copy of this message | ||
Alan, next has worked:
$rlote=new DataObjects_Rel_lote_paises();
$rlote->selectAdd();
$rlote->selectAdd('id_lote');
$rlote->whereAdd('id_pais=250','OR');
$rlote->whereAdd('id_pais=245','OR');
$rlote->whereAdd('id_pais=246','OR');
$rlote->groupBy('id_lote HAVING count(*)=3');
$rlote->find();
Putting "HAVING" in groupBy().
Thank you!
Best regards
mac
--
...ThE PhP_KiD.
-> -----Mensaje original-----
-> De: Alan Knowles [mailto:alan@akbkhome.com]
-> Enviado el: Jueves, 05 de Junio de 2003 12:06 a.m.
-> Para: pear-general@lists.php.net; The Php_kid
-> Asunto: [PEAR] Re: DataObjects "HAVING" ?
->
->
-> Copy and Paste the WhereAdd code.. and call it havingAdd() - looks like
-> the same kind of thing - I've never used having before :)
->
->
->
-> The Php_kid wrote:
-> > Hi !
-> >
-> > There is a way to put a "HAVING" on a SQL sentence with
-> > DataObject ?
-> >
-> > (without use "query()" method)
-> >
-> > ---------------------------------------------
-> >
-> > Example:
-> >
-> > I want to perform next query:
-> >
-> > SELECT id_lot FROM rel_lot_countries
-> > WHERE id_country=251 OR id_country=245 OR id_country=246
-> > GROUP BY id_lot HAVING count(*)=3
-> >
-> > --------------------------------------------------
-> > And, with DataObjects, I have next code:
-> >
-> > $rel_lot_countries=new DataObjects_Rel_lot_countries();
-> > $total=count($_POST['countries']);
-> >
-> > $foreach($_POST['s_countries'] as $val) {
-> > $rel_lot_countries->whereAdd('id_country='.$val,'OR');
-> > }
-> >
-> > $rel_lot_countries->groupBy('id_lot');
->
-> $whereAdd('id_country IN
('.implode(',',$_POST['s_countries']).')');
-> // although you should really 'sanitize the POST...
->
-> Regards
-> Alan
->
->
->
-> >
-> > ????? $rel_lot_countries->having ????
-> >
-> > --------------------------------------------------
-> >
-> > Help me !!
-> > Thank you
-> >
-> > Regards,
-> >
-> > mac
-> > --
-> > ...ThE PhP_KiD.
-> >
-> >
->
->
-> --
-> PEAR General Mailing List (http://pear.php.net/)
-> To unsubscribe, visit: http://www.php.net/unsub.php