PHPackages                             phptricks/database\_class - 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. phptricks/database\_class

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

phptricks/database\_class
=========================

A database class which uses the PDO extension, Supports many drivers

5.0.0(5y ago)3049711MITPHP

Since Apr 30Pushed 4y ago14 watchersCompare

[ Source](https://github.com/anzawi/php-database-class)[ Packagist](https://packagist.org/packages/phptricks/database_class)[ Docs](https://github.com/anzawi/php-database-class)[ RSS](/packages/phptricks-database-class/feed)WikiDiscussions master Synced yesterday

READMEChangelog (8)Dependencies (1)Versions (9)Used By (0)

PDO Database Class
==================

[](#pdo-database-class)

A database class which uses the PDO extension.

- Allows one connection with the database and deny duplicate connection,
- this speeds up to use the database and reduces the load on the server.
- supports many drivers (mysql, sqlite, PostgreSQL, mssql, sybase, Oracle Call Interface -oci-)

If you have any issue please open issue to fix it.

```
any suggestions would you like added or modified write to us at

```

### install via composer

[](#install-via-composer)

```
composer require phptricks/database_class

```

```
{
    "require": {
        "phptricks/database_class": "^5.0"
    }
}
```

---

### Create First Migration :

[](#create-first-migration-)

```
php phptricks migrate:make UsersTable create -table=users

```

### Migrate Tables :

[](#migrate-tables-)

```
php phptricks migrate

```

### Create First Model :

[](#create-first-model-)

```
php phptricks model UserModel --table=users

```

results :

```
use PHPtricks\Orm\Model;
class UserModel extends Model
{
    protected $_table = 'users';
}
```

### Select All Data :

[](#select-all-data-)

```
$user = new UserModel();
$allUsers = $user->select();
```

### Insert Data :

[](#insert-data-)

```
$user = new UsersModel();
$user->insert([
    'username' => 'al-anzawi',
    'email' => 'm.anzawi2013@gmail.com'
]);
```

Full Documentation :
--------------------

[](#full-documentation-)

[PHPtricks-ORM Full Documentation](https://anzawi.github.io/phptricksorm-docs)

#### Change Log :

[](#change-log-)

#### 5.0.0

[](#500)

- ADD : Modeling System
- ADD : Migrations
- ADD : Commands-line
- ADD : Joins \[Models Relation\]
- ADD : `groupBy()` method
- ADD : `toJsonFormatted()` method
- ADD : `drop()` method - to delete tables
- MODIFY : Database Class
- MODIFY : `toArray()` Method

> please note: version 5.0.0 \*\* not \*\* compatible with old versions. if you using PHPtricks-ORM v4.x.x or older in your project and you want to upgrade to v5.0.0, you need to change a lot of things to meet new version.

---

#### 4.1.0

[](#410)

- ADD : `parseWhere(array $cons, $type = "AND")` method
- ADD : `lastInsertedId()` method
- ADD : `createOrUpdate($values, $conditionColumn = [])` method
- ADD : `findBy($column, $value)` method
- REMOVE: `empty()` method

---

#### 4.0.0

[](#400)

- MODIFY : namespace to `PHPtricks\Orm`
- MODIFY : files structure

---

#### 3.1.0

[](#310)

- FIX : Duplicate connection
- ADD : Some methods
    - `each()` -&gt; to each all collection values
    - `map()` -&gt; to map all results
    - `all()` -&gt; to get all results
    - `last()` -&gt; to get last selected record
    - `filter()` -&gt; to filter values
    - `keys()` -&gt; to get collection keys
    - `toJson()` -&gt; to convert results to json format
- ADD : convert results to json format when use collection as string automatically

---

#### 3.0.0

[](#300)

- ADD : direct update functionality
- FIX : `dataView` method with first method
- MODIFY : methods chaining technique
    - `select`, `first`, `find`, `paginate` NOW return Database Object
    - but you can use results as array or object
    - any time you can add `->results()` to convert to array or object

---

#### 2.1.0

[](#210)

- Add : pagination functionality
- Add : count method
- Add : `dataView` method (to display 'selected results' in a table)
- FIX : `in()` method
- FIX : `notIn()` method

---

#### 2.0.0

[](#200)

- ADD : supports multi `drivers`
    - mysql
    - PostgreSQL
    - sqlite
    - msSql
    - sybase
    - Oracle Call Interface (OCI)
- ADD : multi where
- ADD : type of where
- ADD : show query
- FIX : default constraint
- ADD : limit function
- ADD : offset function
- rebuilt 80% of methods
- change License terms

---

#### 1.1.0

[](#110)

- ADD Some Data Definition Language (DDL) functions.
    - ADD Create New Table
    - ADD Drop Table
    - ADD Alter Table
        - ADD new Column
        - Change Column Name
        - Drop Column
        - Rename Column

---

#### 1.0.1

[](#101)

- FIX: `first()` method to compatible with PHP V +5.3.0

---

#### 1.0.0

[](#100)

- First Release

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity68

Established project with proven stability

 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 ~231 days

Recently: every ~338 days

Total

8

Last Release

2097d ago

Major Versions

2.1.0 → 3.0.02016-12-05

3.2.0 → 4.0.02017-04-27

4.1.0 → 5.0.02020-10-03

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8046783?v=4)[mohammad walid anzawi](/maintainers/anzawi)[@anzawi](https://github.com/anzawi)

---

Top Contributors

[![anzawi](https://avatars.githubusercontent.com/u/8046783?v=4)](https://github.com/anzawi "anzawi (95 commits)")

### Embed Badge

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

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

###  Alternatives

[rector/rector-src

Instant Upgrade and Automated Refactoring of any PHP code

136406.3k14](/packages/rector-rector-src)[perplorm/perpl

Perpl is an improved and still maintained fork of Propel2, an open-source Object-Relational Mapping (ORM) for PHP.

2411.8k](/packages/perplorm-perpl)

PHPackages © 2026

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