Help me Complete my PDO Crud Class

21 views
Skip to first unread message

Pavan PHP

unread,
Dec 11, 2012, 9:38:12 PM12/11/12
to php...@googlegroups.com
I am a beginner to intermediate php programmer using mysql_connect and mysql_* functions for curd operations.

As world have changed and I also need to change to adapt the new way, I am trying to implement CRUD using PDO the very first time.

I have created following class:

class PdoCrud {
    var $db;
    var $db_driver = 'mysql'; // mysql or other database driver
    var $db_host = 'localhost';
    var $db_name = 'website';
    var $db_uname = 'root';
    var $db_upass = '';
   
    var $db_dns = $db_driver . ':host='. $db_host.';dbname='.$db_name;
   
    function connectDB() {
        $this->db = new PDO($db_dns, $db_uname, $db_pass);
     }
    function disconnectDB() {
        $this->db = null;
     }
   
    // returns false and logError() in case of error, else returns id of inserted record
    function insertRecord() { }

    // returns false and logError() in case of error, else returns true
    function insertRecords() { }

    // returns false and logError() in case of error, else returns # of rows updated.
    function updateRecord() { }

    // returns false and logError() in case of error, else returns no. of records found
    function findRecord() { }

    // returns false and logError() in case of error, if delete one or multiple records based on criteria
    function deleteRecord() { }

    function logError($errorinfo) {  /* here my code to log error */ }
}

I request you to please help me complete these following functions insertRecord(), insertRecords(), updateRecord(), findRecord() and deleteRecord().

Regards
Pavan PHP

Amit Patil

unread,
Dec 12, 2012, 12:10:12 AM12/12/12
to php...@googlegroups.com
Pavan,

     You will have to start yourself, then only someone help you, I dont think someone will help you from scratch.

Sincerely, 
Amit Patil
http://www.amitpatil.me






Pavan PHP

--
On Twitter ==> http://twitter.com/phpcamp
On Facebook ==> http://www.facebook.com/campersfanpage
 
 
 
You received this message because you are subscribed to the Google
Groups "phpcamp" group.
To post to this group, send email to php...@googlegroups.com

Reply all
Reply to author
Forward
0 new messages