PHPackages                             hadi/database - 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. hadi/database

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

hadi/database
=============

Simple database driver for mysql (PDO)

1.0.1(8y ago)2312981MITPHPPHP &gt;=5.3.0

Since Sep 10Pushed 5y ago2 watchersCompare

[ Source](https://github.com/im4aLL/pdo-mysql-driver)[ Packagist](https://packagist.org/packages/hadi/database)[ RSS](/packages/hadi-database/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependenciesVersions (3)Used By (1)

Updated version can be found here

PDO MySql driver class for PHP
==============================

[](#pdo-mysql-driver-class-for-php)

Introduction
------------

[](#introduction)

This is simple class for SELECT, INSERT, UPDATE, DELETE query for MySQL

Installation
------------

[](#installation)

`composer require hadi/database`

if you don't want composer then simple grab class file from src/Database.php and use it!

Usage
-----

[](#usage)

### Connection

[](#connection)

```
$config = [
    'host' => 'localhost',
    'name' => 'temp',
    'username' => 'root',
    'password' => '',
];

$db = new \Hadi\Database();
$db->connect($config);
```

### Disconnect

[](#disconnect)

```
$db->disconnect();
```

### Select Query

[](#select-query)

#### Method #1

[](#method-1)

```
$db->query('SELECT * FROM users')->get();
```

```
$db->query('SELECT * FROM users')->first();
```

#### Method #2

[](#method-2)

```
$db->table('users')->select([
    'field' => ['name', 'username'],
])->first();
```

```
$db->table('users')->select([
    'field' => ['name', 'username'],
    'condition' => 'WHERE id > 0',
    'limit' => '0, 10',
    'orderby' => 'name',
    'groupby' => 'name',
])->first();
```

### Insert

[](#insert)

Insert data:

```
$db->table('users')->insert(['name' => 'John doe', 'email' => 'john@email.com']);
```

Insert data when supplied email `john@email.com` not exists in table `users`:

```
$db->table('users')->insert(
    ['name' => 'John doe', 'email' => 'john@email.com'],
    ['email']
);
```

##### result

[](#result)

```
affected_row
inserted_id
is_duplicate

```

### Update

[](#update)

Update data where `id = 1`

```
$db->table('users')->update(
    ['name' => 'John doe', 'email' => 'john@email.com'],
    ['id' => 1]
);
```

or

```
$db->table('users')->update(
    ['username' => 'johndoe'],
    'id = 1'
);
```

update `username` if nobody else using same username

```
$db->table('users')->update(
    ['username' => 'johndoe'],
    ['id' => 4],
    ['username']
);
```

##### result

[](#result-1)

```
affected_row
is_duplicate

```

### Delete

[](#delete)

```
$db->table('users')->delete(['id' => 4]);
```

##### result

[](#result-2)

```
affected_row

```

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~0 days

Total

2

Last Release

3216d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1926302?v=4)[Md Habibullah Al Hadi](/maintainers/im4aLL)[@im4aLL](https://github.com/im4aLL)

---

Top Contributors

[![im4aLL](https://avatars.githubusercontent.com/u/1926302?v=4)](https://github.com/im4aLL "im4aLL (10 commits)")

### Embed Badge

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

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

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k117.2M117](/packages/jdorn-sql-formatter)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M87](/packages/propel-propel1)[jfelder/oracledb

Oracle DB driver for Laravel

11518.4k](/packages/jfelder-oracledb)

PHPackages © 2026

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