Re: simple query question...
| From: | Brandon Minton | Date: | Fri, 07 May 2010 01:53:10 +0000 |
| Subject: | Re: simple query question... | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-30517@lists.php.net to get a copy of this message | ||
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
>