Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #14709

Re: multiple open handles to mysql? (loops: fetches within fetches)

From Jerry Stuckle <jstucklex@attglobal.net>
Newsgroups comp.lang.php
Subject Re: multiple open handles to mysql? (loops: fetches within fetches)
Date 2014-12-14 22:47 -0500
Organization A noiseless patient Spider
Message-ID <m6lljb$5hd$1@dont-email.me> (permalink)
References <a48ab39b-7762-4ab5-92d0-f09ec6911caa@googlegroups.com> <o3sjw.910912$Rp.760133@fx23.iad>

Show all headers | View raw


On 12/14/2014 9:54 PM, Richard Damon wrote:
> On 12/11/14, 12:25 AM, oldyork90@yahoo.com wrote:
>>
>> $sth01 blah blah ... bind vars
>> $sth02 (same)
>>
>> while ($seth01->fetch())
>>     while ($seth02->fetch())
>>
>> I'm having difficulty building this with mysql 5.5 and php(mysqli).
>> In an other language/database I can have
>> open and nested active fetches as above.
>>
>> If this is not possible then how is it done?  Do you buffer the whole
>> result, close, and reuse the handle?
>>
>> Thanks - rookie
>>
> 
> I have used successfully something like
> 
> $seth01 = ...
> while($row1 = $seth01->fetch()) {
>   $seth02 = ... /* Build a 2nd query based on the results */
>   while($row2 = $seth02->fetch()) {
>     /* ... */
>   }
> }
> 
> 

Which could mean a lot of calls to MySQL, causing a lot of overhead.
Couldn't you have returned everything in one call to MySQL by using the
appropriate JOINs?

-- 
==================
Remove the "x" from my email address
Jerry Stuckle
jstucklex@attglobal.net
==================

Back to comp.lang.php | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

multiple open handles to mysql? (loops: fetches within fetches) oldyork90@yahoo.com - 2014-12-10 21:25 -0800
  Re: multiple open handles to mysql? (loops: fetches within fetches) Jerry Stuckle <jstucklex@attglobal.net> - 2014-12-11 22:45 -0500
    Re: multiple open handles to mysql? (loops: fetches within fetches) "J.O. Aho" <user@example.net> - 2014-12-12 07:51 +0100
      Re: multiple open handles to mysql? (loops: fetches within fetches) Jerry Stuckle <jstucklex@attglobal.net> - 2014-12-12 09:59 -0500
  Re: multiple open handles to mysql? (loops: fetches within fetches) oldyork90@yahoo.com - 2014-12-14 14:49 -0800
    Re: multiple open handles to mysql? (loops: fetches within fetches) Jerry Stuckle <jstucklex@attglobal.net> - 2014-12-14 19:49 -0500
  Re: multiple open handles to mysql? (loops: fetches within fetches) Richard Damon <Richard@Damon-Family.org> - 2014-12-14 21:54 -0500
    Re: multiple open handles to mysql? (loops: fetches within fetches) Jerry Stuckle <jstucklex@attglobal.net> - 2014-12-14 22:47 -0500
      Re: multiple open handles to mysql? (loops: fetches within fetches) Richard Damon <Richard@Damon-Family.org> - 2014-12-14 23:24 -0500
        Re: multiple open handles to mysql? (loops: fetches within fetches) Jerry Stuckle <jstucklex@attglobal.net> - 2014-12-14 23:57 -0500
          Re: multiple open handles to mysql? (loops: fetches within fetches) Richard Damon <Richard@Damon-Family.org> - 2014-12-19 08:50 -0500
            Re: multiple open handles to mysql? (loops: fetches within fetches) Jerry Stuckle <jstucklex@attglobal.net> - 2014-12-19 11:07 -0500
              Re: multiple open handles to mysql? (loops: fetches within fetches) Richard Damon <Richard@Damon-Family.org> - 2014-12-20 14:51 -0500
                Re: multiple open handles to mysql? (loops: fetches within fetches) Jerry Stuckle <jstucklex@attglobal.net> - 2014-12-20 15:50 -0500

csiph-web