Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.