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


Groups > comp.lang.php > #14702

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

From "J.O. Aho" <user@example.net>
Newsgroups comp.lang.php
Subject Re: multiple open handles to mysql? (loops: fetches within fetches)
Date 2014-12-12 07:51 +0100
Message-ID <cevhkeFfo2oU1@mid.individual.net> (permalink)
References <a48ab39b-7762-4ab5-92d0-f09ec6911caa@googlegroups.com> <m6doc7$grv$1@dont-email.me>

Show all headers | View raw


On 12/12/14 04:45, Jerry Stuckle wrote:
> On 12/11/2014 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
>>
>
> The real question here is - why do you think you need to do this?  And
> your logic is flawed.
>
> Even if you did get two different result sets, the first time through
> the loop $seth02 will be emptied and all future requests will return
> false.  The same thing will occur in any language (and any database).
>
> I think a better solution would be to create the appropriate SQL to
> return the results you want in one request.
>

Just looking at the OP, I would guess the needed change to the query 
would be a JOIN and ORDER BY, as I would guess on that the first query 
fetches data from a group table and the second fetches those items which 
belongs to the group table.

Maybe better option for the OP to ask question about the query itself at 
comp.databases.mysql

-- 

  //Aho

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