PHP-Generic-Database is a set of PHP classes for connecting, displaying and generically manipulating data from a database, making it possible to centralize or standardize all the most varied types and behaviors of each database in a single format, using the standard Strategy, heavily inspired by Medoo and Dibi.
PHP-Generic-Database currently supports the following mechanisms/database:
- Lightweight - Light, simple and minimalist, easy to use and with a low learning curve.
- Agnostic - It can be used in different ways, supporting chainable methods, fluent design, dynamic arguments and static array.
- Easy - Easy to learn and use, with a friendly construction.
- Powerful - Supports various common and complex SQL queries, data mapping and prevents SQL injection.
- Compatible - Supports MySQL/MariaDB, SQLSrv/MSSQL, Interbase/Firebird, PgSQL, OCI, SQLite, and more.
- Auto Escape - Automatically escape SQL queries according to the driver dialect or SQL engine used.
- Friendly - Works well with every PHP framework, such as Laravel, Codeigniter, CakePHP, and frameworks that support singleton extension or composer.
- Free - Under the MIT license, you can use it anywhere, for whatever purpose.
- PHP >= 8.1
- Composer
- Native Extensions
- MySQL/MariaDB (MySQLi) [php_mysqli.dll/so]
- PostgreSQL (PgSQL) [php_pgsql.dll/so]
- Oracle (OCI8) [php_oci8_*.dll/so]
- SQL Server (sqlsrv) [php_sqlsrv.dll/so]
- Firebird/Interbase (ibase: gds | firebird: fds) [php_interbase.dll/so]
- SQLite (SQLite3) [php_sqlite3.dll/so]
- PDO Extensions
- MySQL/MariaDB (MySQL) [php_pdo_mysql.dll/so]
- PostgreSQL (PgSQL) [php_pdo_pgsql.dll/so]
- Oracle (OCI) [php_pdo_oci.dll/so]
- SQL Server (sqlsrv) [php_pdo_sqlsrv.dll/so]
- Firebird/Interbase (ibase: gds | firebird: fds) [php_pdo_firebird.dll/so]
- SQLite (SQLite) [php_pdo_sqlite.dll/so]
- ODBC (ODBC) [php_pdo_obdc.dll/so]
- ODBC Externsions
- MySQL/MariaDB (MySQL) [myodbc8a.dll/so]
- PostgreSQL (PgSQL) [psqlodbc30a.dll/so]
- OCI (ORACLE) [sqora32.dll/so]
- SQL Server (sqlsrv) [sqlsrv32.dll/so]
- Firebird/Interbase (ibase: gds | firebird: fds) [odbcFb.dll/so]
- SQLite (SQLite) [sqlite3odbc.dll/so]
- Access (Access) [aceodbc.dll/so]
- Excel (Excel) [aceodexl.dll/so]
- Text (Text) [aceodtxt.dll/so]
- Optional External Formats
- INI (php native compilation)
- XML (ext-libxml, ext-xmlreader, ext-simplexml)
- JSON (php native compilation)
- YAML (ext-yaml)
- DLLs Compiled from each database engine for each PHP version.
- PHP.ini configuration and extension instalation.
- Edit the php.ini file and remove the ';' for the database extension you want to install.
- The .dll is for Windows and the .so is for Linux/UNIX.
- Uncomment the lines of the extensions you want to enable.
- From
;extension=php_pdo_mysql.dll
;extension=php_pdo_mysql.so
- To
extension=php_pdo_mysql.dll
extension=php_pdo_mysql.so
- Save it, and restart the PHP or Apache Server.
- If the extension is installed successfully, you can find it on phpinfo() output.
- Make sure Composer is installed, otherwise install from the official website.
- Make sure Git is installed, otherwise install from the official website.
- After Composer and Git are installed, clone this repository with the command line below:
git clone https://github.com/nicksonjean/PHP-Generic-Database.git
- Then run the following command to install all packages and dependencies for this project:
composer install
- [Optional] If you need to reinstall, run the following command:
composer setup
- Make sure Docker Desktop is installed, otherwise install from the official website.
- Create an account to use Docker Desktop/Hub, and be able to clone containers hosted on the Docker network.
- Once logged in to Docker Hub and with Docker Desktop open on your system, run the command below:
docker pull php-generic-database:8.1-full
- Docker will download, install and configure a Debian-Like Linux Custom Image as Apache and with PHP 8.1 with all Extensions properly configured.
- Make sure Composer is installed, otherwise install from the official website.
- After Composer are installed, clone this repository with the command line below:
- Add PHP-Generic-Database to the composer.json configuration file.
composer require nicksonjean/php-generic-database
- And update the composer
composer update
Below is a series of readmes containing examples of how to use the lib and a topology image of the native drivers and pdo.
- Connection:
- Strategy:
- Modules:
- Engines:
- MySQL/MariaDB with mysqli: MySQLiConnection.md
- Firebird/Interbase with fbird/ibase: FirebirdConnection.md
- Oracle with oci8: OCIConnection.md
- PostgreSQL with pgsql: PgSQLConnection.md
- SQL Server with sqlsrv: SQLSrvConnection.md
- SQLite with sqlite3: SQLiteConnection.md
- PDO:
- ODBC:
- Statements: Statements.md
- Fetches: Fetches.md
- QueryBuilder:
- Strategy:
- Engines:
- MySQL/MariaDB with mysqli: MySQLiQueryBuilder.md
- Firebird/Interbase with fbird/ibase: FirebirdQueryBuilder.md
- Oracle with oci8: OCIQueryBuilder.md
- PostgreSQL with pgsql: PgSQLQueryBuilder.md
- SQL Server with sqlsrv: SQLSrvQueryBuilder.md
- SQLite with sqlite3: SQLiteQueryBuilder.md
- PDO: PDOQueryBuilder.md
- ODBC: ODBCQueryBuilder.md
PHP-Generic-Database is released under the MIT license.
- Infrastructure
- Creation of the Container in Docker.
- Creation of Migrations between all Databases.
- Source
- Connection
- Possibility of use with Fluent Design and Chained Methods.
- Improved use of the Static Calling format, now using array by key and value for arguments.
- Improved use of the Static Calling format, now using named arguments.
- Adjust in Attribute DEFAULT_FETCH_MODE
- Add file support format connection to XML.
- Add file support format connection to JSON.
- Add file support format connection to INI.
- Add file support format connection to YAML.
- Add file support format connection to NEON.
- Added compatibility for PDO engine.
- Added compatibility for ODBC engine.
- Added compatibility for MongoDB Database.
- Added compatibility for Cassandra Database.
- Added compatibility for SyBase Database.
- Added compatibility for dBase Database.
- Implement fetch and fetchAll methods.
- Add transaction, commit and rollback support.
- QueryBuilder creation for engines.
- QueryBuilder creation for strategy.
- Identify engine version for detect support Pagination Syntax (SQL Server 2008 unsupported pagination nativally).
- Integrate version and compile options in attach in attributes connections.
- Increase new extra connection attribute for ODBC, sets database alias manually.
- Remove connection attribute exception and validate exceptions manually.
- Add boolean feature for cache connections settings.
- Connection