jdt05 Posted August 7, 2007 Share Posted August 7, 2007 Hey everyone, I am a beginner to PHP and at the minute I have a script that does multiple SQL queries. So I have something like $result = pg_query($my_query); After this query I tend to loop through like this to get the result: while ($entry=pg_fetch_row($result)) { //do stuff } But my question is, how can I make a copy of the result? So I don't run the query more than once. Thanks, jdt Quote Link to comment https://forums.phpfreaks.com/topic/63706-solved-postgresql-queries-storing-results-instead-of-multiple-queries/ Share on other sites More sharing options...
wildteen88 Posted August 7, 2007 Share Posted August 7, 2007 $entries = array(); while ($entry=pg_fetch_row($result)) { // ad entry to entries array $entries[] = $entry; //do stuff } echo '<prr>' . print_r($entries, true) . '</pre>'; Quote Link to comment https://forums.phpfreaks.com/topic/63706-solved-postgresql-queries-storing-results-instead-of-multiple-queries/#findComment-317461 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.