Building a database class in PHP

Posted by Sprottenwels on Programmers See other posts from Programmers or by Sprottenwels
Published on 2013-10-18T06:23:38Z Indexed on 2013/10/18 10:15 UTC
Read the original article Hit count: 375

I wonder if I should write a database class for my application, and if so, how to accomplish it?

Over there on SO, a guy mentioned it should be written as an abstract class. However, I can't understand why this would be a benefit.

Do I understand correctly, that if I would write an abstract class, every other class that methods will need a database connection, could simply extend this abstract class and have it's own database object? If so, how is this different from a "normal" class where I could instantiate an database object?

Another method would be to completely forget about my own class and to instantiate a mysqli object on demand.

What do you recommend?

© Programmers or respective owner

Related posts about php

Related posts about architecture