You are here: Re: Objects and Arrays « PHP Programming Language « IT news, forums, messages
Re: Objects and Arrays

Posted by Simon Stienen on 04/03/07 01:41

On 2007-04-02 16-29-44, Jerry Stuckle wrote:
> Your problem is you're reusing $db in your class. When you issue:
>
> $result = $db->query( $select );
>
> You have wiped out the recordset you're using in:
>
> while( $db->next_record() )
>
> If you're going to make another request, you need to use another object.
>
> A real good reason why you shouldn't use globals.

Actually, it's not the global variable that causes the problem, but the bad
design of the DB class. The problem would be the same if he passed the DB
object as a parameter to the ctor - however, if the DB class would be
capable of handling concurrent queries (most likely by letting ::query()
return a result object), the problem wouldn't occur even with a global
variable.

So - yes, the global variable is a desease... but not the one the symptom
is pointing to. :)


HTH

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация