NYCPHP Meetup

NYPHP.org

[nycphp-talk] php mysql question

Brian O'Connor gatzby3jr at gmail.com
Sat Oct 9 16:13:51 EDT 2004


I was just giving those two commands as an example, and my answer was
yes I believe you can and no I don't believe it queries more than
once.  What I believe happens is $result gets set, it then has the
data from the query, and that's what is in the variable.  You can use
the data however you want from there and I don't believe it queries it
again everytime you wish to extract the data from it.

On Sat, 9 Oct 2004 16:51:36 -0300, Henry Ponce <henry at beewh.com> wrote:
> Brian:
> 
> i know this.... and i have no problems doing mysql_num_rows($result) and then
> mysql_fetch_array($result).
> 
> My problem is that i want to query the database once.
> 
> I want to be able to reuse the $result in as many mysql_fetch_array($result)
> as i want. Or i want to know if i can copy $result to another variable(s),
> and then do mysql_fetch_array() or mysql_num_rows() or any other possible
> function on the new variable(s).
> 
> My question is on how to handle this.
> 
> Thanx,
> Henry
> 
> 
> 
> On Saturday 09 October 2004 16:47, Brian O'Connor wrote:
> > If you want to do something along the lines of mysql_num_rows($result)
> > then do mysql_fetch_array($result) I don't believe that queries it
> > twice, and its the same data.
> >
> >
> > On Sat, 9 Oct 2004 14:10:30 -0300, Henry Ponce <henry at beewh.com> wrote:
> > > hello people:
> > >
> > > i was wondering if someone tell me if this is possible...
> > >
> > > i have this:
> > >
> > > $q = 'select * from users';
> > > $result = mysql_query($q);
> > >
> > > There's no problem with that. I want to know if i can do this:
> > >         $newresult = $result;
> > >
> > > I want to run the query once, but use the result set again. Whenever i do
> > > this, $newresult is empty, for example when i place it in:
> > >         while ($row = mysql_fetch_array($newresult)){
> > >
> > >         }
> > >
> > > Can someone tell me the right way of doing this. I don't want to query the
> > > database more than once.
> > >
> > > Thank you,
> > > Henry
> > >
> > > _______________________________________________
> > > New York PHP Talk
> > > Supporting AMP Technology (Apache/MySQL/PHP)
> > > http://lists.nyphp.org/mailman/listinfo/talk
> > > http://www.newyorkphp.org
> > >
> >
> >
> > --
> > Brian O'Connor
> > _______________________________________________
> > New York PHP Talk
> > Supporting AMP Technology (Apache/MySQL/PHP)
> > http://lists.nyphp.org/mailman/listinfo/talk
> > http://www.newyorkphp.org
> >
> >
> >
> 
> 
> 
> _______________________________________________
> New York PHP Talk
> Supporting AMP Technology (Apache/MySQL/PHP)
> http://lists.nyphp.org/mailman/listinfo/talk
> http://www.newyorkphp.org
> 


-- 
Brian O'Connor



More information about the talk mailing list