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().
--
You received this message because you are subscribed to the Google
Group: "Washington, DC PHP Developers Group" - http://www.dcphp.net
To post, send email to washington-dcphp-group@googlegroups.com
To unsubscribe, send email to washington-dcphp-group+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/washington-dcphp-group?hl=en
0 comments:
Post a Comment