I’ve been reading online about the pros and cons of using static methods for accessing data from the database. I have a LAMP based site built on Zend framework.
Some say in terms of performance – there is hardly any difference as quoted here by Greg Beech’s analysis
in calling a method two billion times you could save yourself around 5ms by making it static, which is a saving of approximately nothing for each method call
But if I understand the concept of static methods correctly – there is only one instance of method which means only one DB connection – so on a high traffic website – while one request is being served – the other requests will be queued for the same method right?
So just wanted your thoughts and inputs on whether it makes sense to declare access methods as static or not.
Thanks much
I think you may have a skewed understanding of the processes at hand here.
Every individual request of an individual visitor is served completely independent of each other. Imagine these 2 independent requests:
In other words: basically only the database itself is troubled with queuing the SQL statements.
The PHP scripts work independent of each other. So whether you create instance methods or static methods is completely irrelevant to how the SQL queries are being queued.