Pavan PHP
unread,Dec 11, 2012, 9:41:30 PM12/11/12Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to php
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().