Jump to content

PDO Abstraction Layer?


scriptnerd

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/255903-pdo-abstraction-layer/
Share on other sites

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(){/*....*/}
    ///...
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.