Re: simple query question...
| From: | Mark Steudel | Date: | Thu, 06 May 2010 21:34:36 +0000 |
| Subject: | Re: simple query question... | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-30516@lists.php.net to get a copy of this message | ||
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