For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > January 2007 > [PHP-DB] mysql rereading result set (fetch_assoc)









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author [PHP-DB] mysql rereading result set (fetch_assoc)
larry@lwoods.com

2007-01-09, 7:59 am

I'm running thru a result set using fetch_assoc. Now I want to run through
it again.

How?

TIA,

Larry Woods

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




****************************************
******************************

IMPORTANT NOTICE

This communication is for the exclusive use of the intended recipient(s)
named above. If you receive this communication in error, you should
notify the sender by e-mail or by telephone (+44) 191 224 4461, delete
it and destroy any copies of it.

This communication may contain confidential information and material
protected by copyright, design right or other intellectual property
rights which are and shall remain the property of Piranha Studios
Limited. Any form of distribution, copying or other unauthorised use
of this communication or the information in it is strictly prohibited.
Piranha Studios Limited asserts its rights in this communication and
the information in it and reserves the right to take action against
anyone who misuses it or the information in it.

Piranha Studios Limited cannot accept any liability sustained as a
result of software viruses and would recommend that you carry out your
own virus checks before opening any attachment.

****************************************
********************************
<<<<GWAVAsig>>>>
niel@catweasel.org

2007-01-09, 7:59 am

Hi

> I'm running thru a result set using fetch_assoc. Now I want to run through
> it again.
>
> How?


Save each row into an array first time around, then reset the array
pointer to the beginning, would be one way.

Or assuming you're using the original MySQL functions, use
mysql_data_s(0) to reset the internal result pointer, as one minute
scanning the function list in the documentation would tell you

Niel

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




****************************************
******************************

IMPORTANT NOTICE

This communication is for the exclusive use of the intended recipient(s)
named above. If you receive this communication in error, you should
notify the sender by e-mail or by telephone (+44) 191 224 4461, delete
it and destroy any copies of it.

This communication may contain confidential information and material
protected by copyright, design right or other intellectual property
rights which are and shall remain the property of Piranha Studios
Limited. Any form of distribution, copying or other unauthorised use
of this communication or the information in it is strictly prohibited.
Piranha Studios Limited asserts its rights in this communication and
the information in it and reserves the right to take action against
anyone who misuses it or the information in it.

Piranha Studios Limited cannot accept any liability sustained as a
result of software viruses and would recommend that you carry out your
own virus checks before opening any attachment.

****************************************
********************************
<<<<GWAVAsig>>>>
christine

2007-01-09, 9:58 pm

Hi, I would ask which way is more efficient and save time? Save each row to
array or mysql_data_s(0) ?

Regards & Thanks,
Christine

-----Original Message-----
From: niel@catweasel.org [mailto:niel@catweasel.org]
Sent: Tuesday, January 09, 2007 18:23
To: php-db@lists.php.net
Subject: Re: [PHP-DB] mysql rereading result set (fetch_assoc)

Hi

> I'm running thru a result set using fetch_assoc. Now I want to run

through
> it again.
>
> How?


Save each row into an array first time around, then reset the array
pointer to the beginning, would be one way.

Or assuming you're using the original MySQL functions, use
mysql_data_s(0) to reset the internal result pointer, as one minute
scanning the function list in the documentation would tell you

Niel

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Chris

2007-01-09, 9:58 pm

christine wrote:
> Hi, I would ask which way is more efficient and save time? Save each row to
> array or mysql_data_s(0) ?


Probably mysql_data_s(0).

That just resets the mysql pointer back to the start and so it doesn't
re-run the query or anything like that and doesn't take up any extra memory.

--
Postgresql & php tutorials
http://www.designmagick.com/
Niel Archer

2007-01-09, 9:58 pm

Hi

> Hi, I would ask which way is more efficient and save time? Save each row to
> array or mysql_data_s(0) ?



That totally depends on which resources are more valuable to you.
The array will likely use more memory but be faster to process.
While mysql_data_s(0) would probably use no additional memory but
be slower. It also might require you to duplicate code.

Niel
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com