PHPackages                             keysmash/php-easy-db - 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. keysmash/php-easy-db

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

keysmash/php-easy-db
====================

Easy to use MySQL and PostgreSQL database library for PHP.

v1.0.2(10y ago)1261MITPHPPHP &gt;=5.3.0

Since Jun 9Pushed 10y ago1 watchersCompare

[ Source](https://github.com/sgtkode/PHP-EasyDB)[ Packagist](https://packagist.org/packages/keysmash/php-easy-db)[ Docs](http://keysmashstudios.com)[ RSS](/packages/keysmash-php-easy-db/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (4)Used By (0)

PHP-EasyDB
==========

[](#php-easydb)

\##Easy to use MySQL and PostgreSQL database library for PHP.

Disclaimer: This is a heavily modified version of the database classes used in the PHP Beyond the the Basics Lynda tutorial. I am not trying to steal the original IP.

#### Create a database object using params:

[](#create-a-database-object-using-params)

type, host, database name, user, password

```
// 1 for mysql
$db = new Database(1, "localhost", "foobar", "root", "toor");
// 2 for postgres
$db = new Database(2, "localhost", "foobar", "root", "toor");
```

#### Create base class and extend DatabaseTable

[](#create-base-class-and-extend-databasetable)

```
class Test extends DatabaseTable {
  protected static $table_name = "test";
  protected static $db_fields = array(
    'id',
    'test'
  );
  protected static $db_types = array(
    'int(11) NOT NULL',         // id
    'varchar(11) NOT NULL'     // test
  );

  public $id;
  public $test;

  public static function find_by_test($database, $test){
    $sql = "SELECT * FROM " . static::$table_name . " WHERE test=" . $test;
    $result_array = static::find_by_sql($database, $sql);
    return !empty($result_array) ? $result_array : false;
  }
}
```

#### Get row by id

[](#get-row-by-id)

```
$row = Test::find_by_id($db, 1);
```

#### Use custom function to find row(s)

[](#use-custom-function-to-find-rows)

```
$rows = Test::find_by_test($db, "foobar");
```

#### Get row(s) with specific sql

[](#get-rows-with-specific-sql)

```
$rows = Test::find_by_sql($db, "SELECT * FROM test LIMIT 3 ORDER BY ASC");
```

#### Get array of all rows

[](#get-array-of-all-rows)

```
$rows = Test::find_all($db);
```

#### Loop through rows

[](#loop-through-rows)

```
foreach($rows as $row){
  // do stuff
}
```

#### Get data from row

[](#get-data-from-row)

```
echo $row->test;
```

#### Set row data

[](#set-row-data)

```
$row->test = "foobar";
```

#### Save row

[](#save-row)

```
if($row->save()){
  echo "yeah, it worked!";
} else {
  echo "dang it";
}
```

#### Delete row

[](#delete-row)

```
if($row->delete()){
  echo "yeah, it worked!";
} else {
  echo "dang it";
}
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity60

Established project with proven stability

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

Total

3

Last Release

3975d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/22cf9baa61fb197ac5f157594c0f5e4f11bd9ab12e16a907abee13a5cf6a5a15?d=identicon)[sgtkode](/maintainers/sgtkode)

---

Tags

phpdatabasemysqlpostgresql

### Embed Badge

![Health badge](/badges/keysmash-php-easy-db/health.svg)

```
[![Health](https://phpackages.com/badges/keysmash-php-easy-db/health.svg)](https://phpackages.com/packages/keysmash-php-easy-db)
```

###  Alternatives

[mevdschee/php-crud-api

Single file PHP script that adds a REST API to a SQL database.

3.7k63.8k9](/packages/mevdschee-php-crud-api)[vcian/laravel-db-auditor

Database DB Auditor provide leverage to audit your MySql,sqlite, PostgreSQL database standards and also provide options to add constraints in table.

28535.1k1](/packages/vcian-laravel-db-auditor)[popphp/pop-db

Pop Db Component for Pop PHP Framework

1814.6k11](/packages/popphp-pop-db)[go/db

Database library

6624.1k](/packages/go-db)

PHPackages © 2026

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