scriptnerd Posted January 27, 2012 Share Posted January 27, 2012 Hello guys, I want to build my own Database Class with PDO. This Class should extend the PDO Methods. I heard that i should create an abstraction layer and two different Classes, is that right? First Class should do the connection and the second class has the new methods. My Database Class should have the following methods - select - insert - update Access like: $db->select ($table, $data) { } $db->insert($table, $data) { } $db->update($table, $data) { } I dont know, how i should begin... i know how i can create a PDO Connection, but i haven't a idea how i can do a abstraction layer with PDO... please help me:( I heard that i should use a abstraction layer. One Class for the connection and one class for the methods. Quote Link to comment https://forums.phpfreaks.com/topic/255903-pdo-abstraction-layer/ Share on other sites More sharing options...
kicken Posted January 28, 2012 Share Posted January 28, 2012 Just extend the PDO class and add your own methods to it. class MyDB extends PDO { public function select(){/*...*/} public function update(){/*....*/} ///... } Quote Link to comment https://forums.phpfreaks.com/topic/255903-pdo-abstraction-layer/#findComment-1311865 Share on other sites More sharing options...
scriptnerd Posted January 28, 2012 Author Share Posted January 28, 2012 hello kicken, thanks for you reply. I think it too, that i only should extend the PDO Class:) Thanks Just extend the PDO class and add your own methods to it. class MyDB extends PDO { public function select(){/*...*/} public function update(){/*....*/} ///... } Quote Link to comment https://forums.phpfreaks.com/topic/255903-pdo-abstraction-layer/#findComment-1311918 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.