PHP Classes

DBO: Automate MySQL database access using PDO

Recommend this page to a friend!
  Info   View files Example   View files View files (2)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 364 All time: 6,849 This week: 247Up
Version License PHP version Categories
dbo 1.0.1GNU General Publi...4.5PHP 5, Databases


This class can automate MySQL database access using PDO.

It extends the PDO class and assembles a connection string to connect to a given MySQL database server.

The class can execute prepared queries extracting the query parameter types automatically by parsing the query to get the marks for the parameters of different types.

The query parameter values are passed next to the query parameter.

Picture of John Diaz
  Performance   Level  
Name: John Diaz <contact>
Classes: 3 packages by
Country: Colombia Colombia
Age: 41
All time rank: 289015 in Colombia Colombia
Week rank: 398 Up2 in Colombia Colombia Up
Innovation award
Innovation award
Nominee: 1x



This is only an example script, this must be adapted to your connection params, and use an existing database with existing tables.

$pdoConfig = new stdClass();
$pdoConfig->_database = isset($dbname) ? $dbname : '';
$pdoConfig->_server = isset($servername) ? $servername : '';
$pdoConfig->_user = isset($dbusername) ? $dbusername : '';
$pdoConfig->_password = isset($dbpassword) ? $dbpassword : '';
$pdoConfig->_engine = 'mysql';
$pdoConfig->_showErrors = true;
$DBO = new DBO($pdoConfig);
//Using table prefix
define('TABLE_PREFIX', 'mydb_');
$query = $DBO->query(
"SELECT * FROM {my_table} WHERE id = ? ORDER BY order ASC ", 1
// With param types '%d' = int, '%s' = string, '%b' = boolean
$query1 = $DBO->query(
"SELECT * FROM my_table WHERE id = '%d' ORDER BY order ASC ", 1


// Only the first record
$query2 = $DBO->queryFirst(
"SELECT * FROM my_table WHERE parentId = '%d' ORDER BY order ASC ", 1


  Files folder image Files  
File Role Description
Plain text file DBO.php Class Main DBO Class
Accessible without login Plain text file example.php Example Example file of using DBO class

 Version Control Unique User Downloads Download Rankings  
This week:0
All time:6,849
This week:247Up