Re: nested resultsets
| From: | Brian Huff | Date: | Fri, 19 Jul 2002 14:48:31 +0000 |
| Subject: | Re: nested resultsets | ||
| Groups: | php.windows | ||
| Request: | Send a blank email to php-windows+get-14843@lists.php.net to get a copy of this message | ||
hmmm... Ive had problems in the past with nested JDBC and ODBC result sets... my suggestion would be to execute one result set, and make a copy of the array. Then loop over the copy.
Ideally, tho, you would alter your SQL query so that you dont have to do this looping mechanism at all. SQL is designed to do this kind of junk. Why not execute an inner join between "profile_policy" and the other table? Its probably a lot faster. I dont know what your other table's name is, but it would probably look a lot like this:
SELECT profile_policy.policy_code
FROM profile_policy, other_table
WHERE other_table.code = profile_policy.profile_code
--
Brian 'Bex' Huff
bex@stellent.com
Phone: 952-903-2023
Fax: 952-829-5424
> Hi,
>
> How do I handle nested resultsets??
>
> like i hv
>
> while( $row = $resultSet->fetchRow(DB_FETCHMODE_ASSOC) )
> {
> echo "CODE = ".$row["code"]." NAME =
".$row["name"]."<br>";
>
> $policySQL = "SELECT policy_code from profile_policy where profile_code
=".$row["code"];
>
> $result = $dbSP->query($policySQL);
>
> while($rows = $result->fetchRow(DB_FETCHMODE_ASSOC) )
> {
>
> // now IF I try to echo the result stored in the array $rows, nothing happens. why???
> }
> }
>
> thnx,
> sands
>