PHPackages                             emmanix2002/database-adapter - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. emmanix2002/database-adapter

AbandonedArchivedLibrary[Database &amp; ORM](/categories/database)

emmanix2002/database-adapter
============================

A simple package that abstracts away the process of connecting to a database using PDO and interacting with the connection

v0.0.3(9y ago)0350MITPHPPHP ~7.0

Since Jul 18Pushed 9y ago2 watchersCompare

[ Source](https://github.com/emmanix2002/database-adapter)[ Packagist](https://packagist.org/packages/emmanix2002/database-adapter)[ Docs](https://github.com/emmanix2002/database-adapter)[ RSS](/packages/emmanix2002-database-adapter/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (5)Used By (0)

DatabaseAdapter
===============

[](#databaseadapter)

[![Latest Version on Packagist](https://camo.githubusercontent.com/4c194aa10140868b6aba4d9262a5573ea12621e3dea025b8fe8ec33442ad0c86/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f656d6d616e6978323030322f64617461626173652d616461707465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/emmanix2002/database-adapter)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/e7788b2154b732c93185bc190dfab52b35ba63ad6ccc02bf8f48fc3ad5270c59/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f656d6d616e6978323030322f64617461626173652d616461707465722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/emmanix2002/database-adapter)[![Coverage Status](https://camo.githubusercontent.com/28e0970b29ab87803c8978912d067ce9aa67a65a51ceae256296187ceca78f33/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f656d6d616e6978323030322f64617461626173652d616461707465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/emmanix2002/database-adapter/code-structure)[![Quality Score](https://camo.githubusercontent.com/e5aec25900f1775b14fff6bcbdde7752f0376d6a2860596c578528291715e2c6/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f656d6d616e6978323030322f64617461626173652d616461707465722e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/emmanix2002/database-adapter)[![Total Downloads](https://camo.githubusercontent.com/be8ce1d61cde4d4af64c081b9013fa882b97203934b7fce22894bb2e23395572/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f656d6d616e6978323030322f64617461626173652d616461707465722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/emmanix2002/database-adapter)

A simple package that abstracts away the process of connecting to a database using `PDO` and interacting with the connection.
All code is written using PSR1 and PSR2 guidelines.

Install
-------

[](#install)

Via Composer

```
$ composer require emmanix2002/database-adapter
```

Usage
-----

[](#usage)

We start by creating an instance of the class; it provides a utility `create()` method that takes in the settings as an array and fills in defaults where needed.
It is possible to change the defaults by calling the `setDefault()` static method.

```
$config = ['host' => 'localhost', 'user' => 'user', 'password' => 'password', 'schema' => 'schema_name'];

$adapter = Emmanix2002\MySqlAdapter::create($config);
// OR
$adapter = new Emmanix2002\MySqlAdapter('host', 'schema_name', 'user', 'password');

$record = $adapter->selectOne('SELECT * FROM `Users` WHERE `user_id`=?', 21134);
var_dump($record);
```

### Usage: defaults

[](#usage-defaults)

```
use Emmanix2002\MySqlAdapter;

MySqlAdapter::setDefault('host', 'default_hostname');
MySqlAdapter::setDefault('schema', 'default_schema');
MySqlAdapter::setDefault('user', 'default_user');
MySqlAdapter::setDefault('password', 'default_password');

$adapterDefault = MySqlAdapter::create();
// create an adapter using the defaults

$adapter = MySqlAdapter::create(['host' => 'another_hostname']);
// equivalent to new MySqlAdapter('another_hostname', 'default_schema', 'default_user', 'default_password');
```

### Usage: Querying

[](#usage-querying)

There are a few methods that help with querying, they are:

- `exec()`
- `selectAll()`
- `selectOne()`

`exec()` should be called directly for all queries that do not return an actual response i.e. every query excluding `SELECT`statements. It is called by both `select*()` methods, but it's much easier using them for `SELECTing` as opposed to calling `exec()` yourself. `exec()` uses `prepared statements` on all queries passed to it.
Below are examples:

```
$sql = 'SELECT * FROM `users` WHERE `user_email`=? AND `user_status`=?';
$record = $adapter->selectOne($sql, 'username@example.com', 1);

// it is also possible to do the same like so:
$args = ['username@example.com', 1];
$record = $adapter->selectOne($sql, ...$args);

// both will return the same value
```

`exec()` always returns a value; depending on the arguments passed:

- `true`: is returned if the query was successfully executed and the `$isSelect` parameter is set to `FALSE`
- `false`: is returned if the query execution failed, irrespective of the value of the `$isSelect` parameter
- `array`: is returned if the query was successful and the `$isSelect` parameter is set to `TRUE`. `select*()` methods always set `$isSelect` to `TRUE`

Change log
----------

[](#change-log)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Testing
-------

[](#testing)

```
$ composer test
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Okeke Emmanuel](https://github.com/emmanix2002)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

25

—

LowBetter than 36% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 93.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~9 days

Total

3

Last Release

3615d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/456165?v=4)[Emmanuel Okeke](/maintainers/emmanix2002)[@emmanix2002](https://github.com/emmanix2002)

---

Top Contributors

[![emmanix2002](https://avatars.githubusercontent.com/u/456165?v=4)](https://github.com/emmanix2002 "emmanix2002 (15 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (1 commits)")

---

Tags

databaseemmanix2002database-adapter

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/emmanix2002-database-adapter/health.svg)

```
[![Health](https://phpackages.com/badges/emmanix2002-database-adapter/health.svg)](https://phpackages.com/packages/emmanix2002-database-adapter)
```

###  Alternatives

[doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.

9.7k595.8M6.5k](/packages/doctrine-dbal)[doctrine/orm

Object-Relational-Mapper for PHP

10.2k295.3M7.2k](/packages/doctrine-orm)[doctrine/doctrine-bundle

Symfony DoctrineBundle

4.8k249.9M3.9k](/packages/doctrine-doctrine-bundle)[doctrine/migrations

PHP Doctrine Migrations project offer additional functionality on top of the database abstraction layer (DBAL) for versioning your database schema and easily deploying changes to it. It is a very easy to use and a powerful tool.

4.8k212.9M508](/packages/doctrine-migrations)[doctrine/data-fixtures

Data Fixtures for all Doctrine Object Managers

2.9k141.0M563](/packages/doctrine-data-fixtures)[robmorgan/phinx

Phinx makes it ridiculously easy to manage the database migrations for your PHP app.

4.5k47.9M443](/packages/robmorgan-phinx)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
