yorch / mydb
Abstract Class to manage RDBMS (MySQL, MSSQLServer, ODBC, PostgreSQL) connections
Requires
- php: >=5.4.0
- monolog/monolog: 1.13.1
This package is auto-updated.
Last update: 2025-04-29 00:35:31 UTC
README
Description
Abstract Class to manage RDBMS (MySQL, MSSQLServer, ODBC, PostgreSQL) connections
Requirements
Developer Documentation
Execute phpdoc -d MyDb/
Installation
Create file composer.json
{ "require": { "yorch/mydb": "dev-master" } }
Execute composer.phar install
Example
// 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;
Notes
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 :(.
References
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
Donate
P.D. Let's go play !!!