Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/omarajmi/dalphppdo
Php database abstraction layer using PDO
https://github.com/omarajmi/dalphppdo
database database-abstraction database-layer php-library php7 php71
Last synced: 3 months ago
JSON representation
Php database abstraction layer using PDO
- Host: GitHub
- URL: https://github.com/omarajmi/dalphppdo
- Owner: omarAjmi
- License: mit
- Created: 2018-04-13T18:23:20.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-04-16T22:38:36.000Z (over 6 years ago)
- Last Synced: 2024-10-12T12:22:38.425Z (3 months ago)
- Topics: database, database-abstraction, database-layer, php-library, php7, php71
- Language: PHP
- Homepage:
- Size: 53.7 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# DALphpPDO Version 1.0
**DALphpPDO** is a **php** library that allows you to connect, query and obtain results from all major relational dbms.
## List of supported **RDBMS**:
- [Mysql](https://www.mysql.com/) (default)
[PostgresSQL](https://postgresql.org/).
[Oracle](https://www.oracle.com/database)
[SqlServer](https://www.microsoft.com/en-us/sql-server)
[SqlLite](https://sqlite.org/)
[Ibm](https://www.ibm.com/db2/)
[Sybase](http://www.sybase.com/)
[Odbc](https://docs.microsoft.com/en-us/sql/odbc/microsoft-open-database-connectivity-odbc)## Loading Database connection configurations:
configurations residesin the **/Settings.php** file.
**Example of Mysql configs:**'mysql' => [ //the default pool (driver)
'driver' => 'mysql',
'host' => 'localhost',
'dbname' => 'database_name',
'user' => 'user',
'password' => 'passwd',
'prefix' => 'DB1_',
'port' => 3306,
'persistent' => 1,
'fetchmode' => 'object',
'prepare' => 1
],
configurations are devised as pools, each pool hase the correspondant RDBMS driver name as a global name for the pool like the exemple above.
loading these configurations is strait forward:$configs = new DatabaseConfiguration();
/**
* without parameters loads the default configurations
* for the default pool which is mysql
*/
or:$configs = new DatabaseConfiguration('pgsql');
or
$configs = new DatabaseConfiguration('odbc', 'path/to/settings/file');
## Creating a connection instance:
creating the connection instance requires a DatabaseConfiguration object that holds all the necessary parameters to open a connection throgh PHP's PDO.
creating a connection instance is strait forward:$dbConnect = new DatabaseConnection($configs);
## Querying databases:
for database queries you need to instantiate the QueryBuilderBase which is the engin that generates SQL queries and execute them without the need to deal directly with SQL syntax.
all this object needs is the DatabaseConnection object that holds all the necessary infos for the database connection.$qb = new QueryBuilderBase($dbConnect);
### creating queries:
creating queries is as simple as creating native SQL queries.
#### Select:$qb->select('column_name')->from('table_name');
//selects a spesific column from the spesific table
or$qb->select(['column_name', 'column_name',...])->from('table_name');
//selects multiple columns from the spesific table
or$qb->select()->from('table_name');
//selects all columns from the spesific table#### Where:
$qb->select('column_name')->from('table_name')->where("column = value");
#### and where:$qb->select('column_name')->from('table_name')->where("column = value")->andWhere("column = value");
#### or where:$qb->select('column_name')->from('table_name')->where("column = value")->orWhere("column = value");
#### groupBy
$qb->select('column_name')->from('table_name')->where("column = value")->orWhere("column = value")->groupBy("column_name");