PHPackages                             bdb/bdb - 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. bdb/bdb

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

bdb/bdb
=======

CRUD MySql Easily

1.01(6y ago)05MITPHPPHP &gt;=5.6

Since Nov 1Pushed 6y ago1 watchersCompare

[ Source](https://github.com/BeniWAdi/BDB)[ Packagist](https://packagist.org/packages/bdb/bdb)[ RSS](/packages/bdb-bdb/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

BDB
===

[](#bdb)

PHP library to (Create, Read, Update, Delete) in Mysql databases.

Database example
----------------

[](#database-example)

Database example scheme:

```
CREATE TABLE `category` (
    `id`    INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT UNIQUE,
    `name`  TEXT
);

CREATE TABLE `tag` (
    `id`    INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT UNIQUE,
    `name`  TEXT
);

CREATE TABLE `post` (
    `id`    INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT UNIQUE,
    `title` TEXT,
    `category_id` INTEGER,
    `type`  TEXT,

    FOREIGN KEY(`category_id`) REFERENCES category(id)
);

CREATE TABLE `post_tag` (
    `id`    INTEGER NOT NULL PRIMARY KEY AUTO_INCREMENT UNIQUE,
    `tag_id`   INTEGER NOT NULL,
    `post_id`  INTEGER NOT NULL,

    FOREIGN KEY(`tag_id`) REFERENCES tag(id),
    FOREIGN KEY(`post_id`) REFERENCES post(id)
);
```

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

[](#installation)

Download package BDB, copy into your project. Open `BDB/BConfig.php` to setup configuration.

```
class BConfig {

    protected static $servername = "localhost";
    protected static $username = "root";
    protected static $password = "";
    protected static $dbname = "post";
    protected static $charset = "utf8";

    protected static $showError = true;
    protected static $showSqlWhenError = true;
    protected static $killAppWhenError = true;

}

```

Run `BDB/RunMe.php` copy the output script into `BDB/DBReader.php`

Usage
-----

[](#usage)

### Select

[](#select)

#### findByPk

[](#findbypk)

Returns a record from matched `id`. If nothing got matched `null` will be returned.

```
$post = BDB::findByPk("post", 1);
echo "Title : ".$post["title"];
echo "Category : ".$post["category"]["name"];
```

#### findAll

[](#findall)

Returns all record from selected `table`. If no record `null` will be returned.

```
$allPost = BDB::findAll("post");
foreach ($allPost as $post){
	echo "Title : ".$post["title"];
	echo "Category : ".$post["category"]["name"];
}
```

#### findAllByFields

[](#findallbyfields)

Returns all record from matched dataset. If nothing got matched `null` will be returned.

```
$allPost = BDB::findAllByFields("post", ["title" => "Football", "category.name" => "sport"]);
foreach ($allPost as $post){
	echo "Title : ".$post["title"];
	echo "Category : ".$post["category"]["name"];
```

### Insert

[](#insert)

Inserting data into database follow the example below:

```
$data = [
    "title" => "Post title",
    "text" => "Post text",
    "category_id" => 1
    ];
BDB::insert("post", $data);
```

Returns `ture` for a successful insert, `false` if not.

### Update

[](#update)

Updating from matched `id`. If the update succeeded `true` will be returned, `false` if not.

```
$id = 1;
$data = [
    "title" => "New title",
    "text" => "new text"
    ];
BDB::update("post", $data, $id);
```

Updating from matched dataset. If the update succeeded `true` will be returned, `false` if not.

```
$conds = ["title"=>"Football", "category.name" => "sport"];
$data = [
    "title" => "New title",
    "text" => "new text"
    ];
BDB::update("post", $data, $conds);
```

### Delete

[](#delete)

Deleting from matched `id`. If the update succeeded `true` will be returned, `false` if not.

```
BDB::delete("post", 1);
```

Deleting from matched dataset. If the update succeeded `true` will be returned, `false` if not.

```
$conds = ["title"=>"Football", "category.name" => "sport"];
BDB::delete("post", $conds);
```

### Query

[](#query)

To create your custom `query`. First `parameter` for `sql statement`, second `parameter` for `paramValues`, third `parameter` for `bind paramTypes` defaults `string`.

```
$sql = "SELECT id FROM post WHERE id = :id AND title = :title";
$paramValues = [":id"=>1, ":title"=>"Football"];
$paramTypes = ["id"=> PDO::PARAM_INT];
$result = BDB::query($sql, $paramValues, $paramTypes);
```

Returns will be `multiples array` or `null` if `count(column) > 0`, `bool` if `count(column) = 0`.

### API

[](#api)

FunctionParametersReturn`findByPk``$tableName, $primaryKey``array`/`null``findAll``$tableName, $additionalQuery = ""``array`/`null``searchAll``$tableName, $fieldsCompare, $keyword, $additionalQuery = ""``array`/`null``findAllByFields``$tableName, array $fields, $additionalQuery = ""``array`/`null``insert``$tableName, array $fields``bool``update``$tableName, array $fields, $pkOrFields, $operator = "AND"``bool``delete``$tableName, $pkOrFields, $operator = "AND"``bool``query``$statement, array $bindValues = null, array $bindTypes = null, $returnOption = 0``Mixed``beginTransaction``bool``rollBackTransaction``bool``commitTransaction``bool``isInTransaction``bool`

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

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

Unknown

Total

1

Last Release

2386d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/23f045e022629699b1a507f85dddb9d6697ac2afd17a16baa25d88c8e09451cc?d=identicon)[BeniWAdi](/maintainers/BeniWAdi)

---

Top Contributors

[![BeniWAdi](https://avatars.githubusercontent.com/u/30317527?v=4)](https://github.com/BeniWAdi "BeniWAdi (16 commits)")

### Embed Badge

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

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

###  Alternatives

[doctrine/orm

Object-Relational-Mapper for PHP

10.2k285.3M6.2k](/packages/doctrine-orm)[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k115.1M102](/packages/jdorn-sql-formatter)[illuminate/database

The Illuminate Database package.

2.8k52.4M9.4k](/packages/illuminate-database)[mongodb/mongodb

MongoDB driver library

1.6k64.0M546](/packages/mongodb-mongodb)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

90340.3M211](/packages/ramsey-uuid-doctrine)[reliese/laravel

Reliese Components for Laravel Framework code generation.

1.7k3.4M16](/packages/reliese-laravel)

PHPackages © 2026

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