MDB2 nested queries problem
| From: | Sina Salek | Date: | Thu, 09 Nov 2006 14:51:29 +0000 |
| Subject: | MDB2 nested queries problem | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-25743@lists.php.net to get a copy of this message | ||
Hi every one,
I have a problem with MDB2 when i want to use it inside loop, like below
code.
when reaches second query, it overrides result of the first query, so
loop doesn't work properly anymore.
for example if second query does empty, loop level one stops!.
i searched the manual and also source code , but i couldn't find any way
to solve it. i used different methods to connect like factory but didn't
change anything.
so would you please help me if you know what is wrong?
<?php
$queryResultLevel1 = &$storage->query('SELECT * FROM users');
while ($rowLevel1=$queryResultLevel1->fetchRow(MDB2_FETCHMODE_ASSOC)) {
echo "Photos of user ".$rowLevel1['name']." : <br/>";
$queryResultLevel2 = &$storage->query('SELECT * FROM
users_photos WHERE user_id='.$rowLevel1['id']);
while
($rowLevel2=$queryResultLevel2->fetchRow(MDB2_FETCHMODE_ASSOC)) {
echo "- ".$rowLevel2['filename']."<br/>";
}
}
?>