simple query question...
| From: | Brandon Minton | Date: | Thu, 06 May 2010 20:22:07 +0000 |
| Subject: | simple query question... | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-30515@lists.php.net to get a copy of this message | ||
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?