Re: simple query question...

From: Date: Fri, 07 May 2010 06:19:32 +0000
Subject: Re: simple query question...
References: 1 2 3 4  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-30519@lists.php.net to get a copy of this message
Yeah, mdb2 is definitely the preferred abstraction layer. My client however was using DB and not paying me to upgrade their system so you work with what you're handed at times. I can only suggest what's in their best interest. In this case though, it looks like the syntax would be nearly the same except for an mdb2 objects over a db object if I'm correct. On Fri, May 7, 2010 at 12:36 AM, Mark Steudel <msteudel@gmail.com> wrote: > I'm not positive but I thought mdb2 was the preferred db abstraction layer > for pear repos ... If you are learning db you might want to just jump to > mdb2. > > Sent from my iPhone > > On May 6, 2010, at 6:53 PM, Brandon Minton <brandon.minton@gmail.com> wrote: > >> Yes, got it now.  The parameters were not as the query prototype >> dictates.  I think delving deeper into the pear documentation would be >> in my best interest at this point but this list is a nice 2nd option. >> Thanks Mark! >> >> .Brandon >> >> On Thu, May 6, 2010 at 5:34 PM, Mark Steudel <msteudel@gmail.com> wrote: >>> >>> Looks like your parameterized query is wrong: >>> >>> $res = $db->query("SELECT table_2.* ". >>>                                              "FROM table_1, >>> table_2 ". >>>                                               "WHERE >>> table_1.patient_id=?" . >>>                                               "AND >>> table_1.table_1_id = table_2.table_1_id", $pid); >>> >>> Note that $db->query takes two arguments here. >>> >>> MS >>> On Thu, May 6, 2010 at 1:22 PM, Brandon Minton <brandon.minton@gmail.com> >>> wrote: >>>> >>>> Can someone help me replicate a simple select in pear:DB?  (I know >>>> it's deprecated but I'm not upgrading the client's db abstraction >>>> layer atm) >>>> >>>> Using mysql command-line or phpMyAdmin, this query works like a charm: >>>> >>>> SELECT table_2 . * >>>> FROM table_1, table_2 >>>> WHERE table_1.patient_id =132 >>>> AND table_1.table_1_id = table_2.table_1_id >>>> >>>> >>>> here is my pear::DB code: >>>> >>>>       $pid = '132'; >>>>       $arr = array(); >>>>       $res = $db->query("SELECT table_2.* ". >>>>                                               "FROM >>>> table_1, table_2 ". >>>>                                               "WHERE >>>> table_1.patient_id=?",array( $pid ), >>>>                                               "AND >>>> table_1.table_1_id = >>>> table_2.table_1_id"); >>>>       while ($row = $res->fetchRow(DB_FETCHMODE_ASSOC)) >>>>       { >>>>        $arr[] = $row; >>>>       } >>>>       return $arr; >>>> >>>> The above code returns all rows from table_2 and does it twice. >>>> What's wrong with my pear:DB query? >>>> >>>> -- >>>> PEAR General Mailing List (http://pear.php.net/) >>>> To unsubscribe, visit: http://www.php.net/unsub.php >>>> >>>> >>> >>> >>> >>> -- >>> >>> ----------------------------------------- >>> Mark Steudel >>> P: 206.375.7244 >>> msteudel@gmail.com >>> >>> . : Work : . >>> http://www.mindfulinteractive.com >>> >>> . : Play : . >>> http://www.steudel.org/blog >>> >

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