Re: OOP PHP with MySQLi



Citrus wrote:

>> What a lot of overhead and such.
>> I am glad I just use global $connection; whereever I need it.
>
> Where exactly do you find any overhead ? My project will consist out of 15
> or more objects with each over 20 or 30 functions. Almost every function
> will need to use a database connection. Calling global $connection at the
> start of every script and function.. THAT is overhead.

No it is not.
That is just an opinion.
How do you want to compare? Counting?

But all is fine with me: Code whatever way feels good and structured to you.

I just do not see the advantage, but that is not important.

Don't get me wrong: I come from a Java (J2EE) background so I know my way
just fine with objects.
That is also why I like PHP so much: I can throw in objects when I need
them, where Java made me use objects for even the most simplest
functionality.
I often see people getting all happy and joyous about objects, while object
are just another way of doing what you were doing before without objects.
Smart designed functions can give you almost the same flexibility.
I just had the impression you wanted to use objects for your connection,
because that sounded cool, and I just wanted to tell you there is nothing
wrong with global $connection.

But I still wonder why you said that global $connection is bad programming.
Care to explain that?
I am just curious what made you claim that.

Regards,
Erwin Moller
.



Relevant Pages

  • Re: Design / best practices question
    ... what do you think the overhead is to instantiate a SQL connection? ... What I am challenging here is whether the creation of the SQL connection is really a problem. ... Under load, the pool will retain all of the connection objects, so the overhead, per call, is in the millisecond range at max and more likely to be microseconds. ... On heavily used apps, ADO.NET is constantly pulling from the connection pool, so the instantiation time is reduced tremendously. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Design / best practices question
    ... values to the database. ... what do you think the overhead is to instantiate a SQL connection? ... even with sudden heart failure on your system. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: only 11Mb/s with bcm43xx on F5?[Scanned]
    ... But because there is the overhead of encryption and decryption, ... but I do not expect it to be as fast as the wired connection. ... overhead with the wireless connection if you are using WEP or WPA. ...
    (Fedora)
  • Re: only 11Mb/s with bcm43xx on F5?[Scanned]
    ... But because there is the overhead of encryption and decryption, ... but I do not expect it to be as fast as the wired connection. ... overhead with the wireless connection if you are using WEP or WPA. ...
    (Fedora)
  • Re: OOP PHP with MySQLi
    ... > I am glad I just use global $connection; ... Where exactly do you find any overhead? ... should only be a 'public' statement before function SQL. ... public function SQL() { ...
    (comp.lang.php)