Please Help me to complete my PDO Crud Class

30 views
Skip to first unread message

Pavan PHP

unread,
Dec 11, 2012, 9:41:30 PM12/11/12
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().

Adnan358 Php

unread,
Jan 22, 2017, 9:18:52 AM1/22/17
to php
Where is github link ? Your class can get more help in github

12 Aralık 2012 Çarşamba 04:41:30 UTC+2 tarihinde Pavan PHP yazdı:

Collin Peng

unread,
Feb 19, 2017, 9:09:42 AM2/19/17
to php
I think you need to do it for youself, rather than seek the help of others.

You can read the Zend Framework source code to learn how to use the PDO.

在 2012年12月12日星期三 UTC+8上午10:41:30,Pavan PHP写道:

Adnan bilaç

unread,
Feb 20, 2017, 1:38:15 AM2/20/17
to p...@googlegroups.com
what dou you want me to do ?

--
You received this message because you are subscribed to a topic in the Google Groups "php" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/php/snGUb7x1ip0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to php+unsubscribe@googlegroups.com.
To post to this group, send email to p...@googlegroups.com.
Visit this group at https://groups.google.com/group/php.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages