Re: Merge result set of query?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Martin Norland wrote:
Jochem Maas wrote:

Martin Norland wrote:

....

while (($row = mysql_fetch_row($result)) || ($row = mysql_fetch_row($result2)))
{
// just do it. â
}



.. work (due to shortcircuiting)? and how ugly is it?

    // foo
}


That would work if you just wanted to iterate over both resultsets and do the same thing, yes. Say, if you had lists of users who signed up for something in two separate databases, you could print them all out with that. Since he said union and not join - that is probably his intention.

that was what I had in mind when it popped into my head :-)


I can't decide if that code is beautiful or horribly ugly though... I would have to say it's beautiful so long as the 'just do it' is very short - if the 'just do it' should be a function - then you should just suck it up and do two while's. Also, for every result in $result2, you have to poke at the first database and say "any more yet?", which is hackish.


slick 'obfuscated perl' entry type fix though :) [okay, it's not obfuscated in the traditional sense]

ok, I apprieciate your comments - its always good to get a experienced 'hackers' view on things. thank you Martin!


cheers,

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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux