Abstract Class to manage RDBMS (MySQL, MSSQLServer, ODBC, PostgreSQL) connections
Execute phpdoc -d MyDb/
Create file composer.json
{ "require": { "yorch/mydb": "dev-master" } }
Execute composer.phar install
// Mysql Example
$provider = 'MySQLDb';
$hostname = '';
$username = '';
$password = '';
$dbname = '';
$dbMySQL = MyDb::getInstance($provider, $hostname, $username, $password, $dbname, 3306);
$query = sprintf("SELECT 1 AS %s", $dbMySQL->escape($provider));
// Associate
print_r($dbMySQL->executeCommand($query));
// Enumerate
print_r($dbMySQL->executeCommand($query, null, MyDb::ENUM));
$dbMySQL = null;
The SQL Server connection only works in MS Windows.
For PostgreSQL the parameters in SQL Query must be $#. example: 'SELECT * FROM MYTABLE WHERE ID = $1 AND DESCRIPTION = $2'
For ODBC connection, if the query insert uses ? parameters throw this error (COUNT field incorrect or syntax error).
Sorry, my english is bad :(.
http://es.wikipedia.org/wiki/Patr%C3%B3n_de_dise%C3%B1o
http://es.wikipedia.org/wiki/Singleton
http://es.wikipedia.org/wiki/Abstract_Factory
P.D. Let's go play !!!