PHPackages                             bera/bera-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. bera/bera-db

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

bera/bera-db
============

A simple database abstraction layer

v1.0.5(3y ago)010411MITPHP

Since Aug 8Pushed 3y ago1 watchersCompare

[ Source](https://github.com/joykumarbera/bera-db)[ Packagist](https://packagist.org/packages/bera/bera-db)[ RSS](/packages/bera-bera-db/feed)WikiDiscussions main Synced today

READMEChangelog (6)DependenciesVersions (7)Used By (1)

Bera Db
=======

[](#bera-db)

A simple mysql database warpper for php

Badges
------

[](#badges)

[![MIT License](https://camo.githubusercontent.com/7c124530b7c185c6928998842a1a52ed4bfd21071bf67db8f325f470cc3160a3/68747470733a2f2f696d672e736869656c64732e696f2f61706d2f6c2f61746f6d69632d64657369676e2d75692e7376673f)](https://github.com/tterb/atomic-design-ui/blob/master/LICENSEs)

Authors
-------

[](#authors)

- [@joykumarbera](https://www.github.com/joykumarbera)

Features
--------

[](#features)

- Simple Interface
- Add, Edit, Delete, Fetch query helper methods
- Database transactions

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

[](#installation)

Install by using composer

```
  composer require bera/bera-db
```

Usage/Examples
--------------

[](#usageexamples)

Setup a connection

```
require_once __DIR__  . '/vendor/autoload.php';

use Bera\Db\Db;

try {
    $db = new Db('music_app', 'localhost', 'root', '', null, true);
} catch( Bera\Db\Exceptions\DbErrorException $e  ) {
    echo $e->getMessage();
}
```

Insert data

```
    $db->insert('songs', [
        'title' => 'A New Songs',
        'author' => 'dev',
        'duration' => 300
    ]);
```

Update data

```
 $db->update('songs', [
        'title' => 'Another Songs'
    ], ['id' => 1]);
```

Delete data

```
$db->delete('songs', ['id' => 1]);
```

Select data

```
$db->query('SELECT * FROM songs')->all()
$db->query('SELECT * FROM songs WHERE id = ?', [1])->one()
$db->findAll('songs');
$db->findOne('songs', ['id' => 1]);
```

API Reference
-------------

[](#api-reference)

#### Connect to a database

[](#connect-to-a-database)

```
 $db = new Db('music_app', 'localhost', 'root', '', null, true);
```

#### Set debug mode

[](#set-debug-mode)

```
 $db->setDebugMode(true)
```

#### Insert data

[](#insert-data)

```
 $db->insert('table_name', $data = [])
```

#### Update data

[](#update-data)

```
 $db->update('table_name', $data = [], $conditions = [])
```

#### Delete data

[](#delete-data)

```
 $db->delete($table, $conditions=[], $glue = 'AND')
```

#### Delete data using AND as a glue

[](#delete-data-using-and-as-a-glue)

```
 $db->deleteUsingAnd($table, $conditions=[])
```

#### Delete data using OR as a glue

[](#delete-data-using-or-as-a-glue)

```
 $db->deleteUsingOr($table, $conditions=[])
```

#### Run raw query

[](#run-raw-query)

```
 $db->query($sql, $params = [])
```

#### Get total nunmber of affected rows

[](#get-total-nunmber-of-affected-rows)

```
 $db->getAffectedRows()
```

#### Get last insert id

[](#get-last-insert-id)

```
 $db->lastInsertId()
```

#### Get single record as an array after query

[](#get-single-record-as-an-array-after-query)

```
 $db->query($sql, $params = [])->one()
```

#### Get single record as an object after query

[](#get-single-record-as-an-object-after-query)

```
 $db->query($sql, $params = [])->oneAsObject()
```

#### Get all records as an array after query

[](#get-all-records-as-an-array-after-query)

```
 $db->query($sql, $params = [])->all()
```

#### Get a single record using a table name

[](#get-a-single-record-using-a-table-name)

```
 $db->findOne($table, $conditions = [], $glue = 'AND', $as = 'object');
```

#### Get all records using a table name

[](#get-all-records-using-a-table-name)

```
 $db->findAll($table, $conditions = [], $glue = 'AND');
```

#### Begin a db transaction

[](#begin-a-db-transaction)

```
 $db->start_transaction()
```

#### End a db transaction

[](#end-a-db-transaction)

```
 $db->end_transaction()
```

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 93.3% 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 ~35 days

Recently: every ~42 days

Total

6

Last Release

1247d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/83c1f3f5cf258ade50e6452be4f3108dc06bac26c222904b640e70e1e1c5c83e?d=identicon)[bera.dev.007](/maintainers/bera.dev.007)

---

Top Contributors

[![joykumarbera](https://avatars.githubusercontent.com/u/47684470?v=4)](https://github.com/joykumarbera "joykumarbera (14 commits)")[![desunbera](https://avatars.githubusercontent.com/u/92908316?v=4)](https://github.com/desunbera "desunbera (1 commits)")

---

Tags

databasedb-wrappermysqlphpphp-dbsql

### Embed Badge

![Health badge](/badges/bera-bera-db/health.svg)

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

###  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)
