![]() |
Classes and MySQLi
I think its me missing a one of the major crux's of Object Orientated programming, but I've been looking for an answer to this problem for years now, and I've never been able to get a clear cut answer.
Here's a class that i've written: PHP Code:
Now everytime this class is initiated the database connection is restarted. PHP Code:
So what am i missing about using a database in an Object Orientated fashion should model_element extend mysqli? Or is that wrong aswell. Thanks for any help in advance. Oli. |
It was actually pretty easy once I really thought about it. What i needed to do was call initiate MySQLi via a child class which uses the singleton pattern.
Somebody will Probably find this quite useful. database.php PHP Code:
PHP Code:
PHP Code:
|
| All times are GMT. The time now is 03:56 AM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0