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

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

kubricklabs/database
====================

Database package for the KubrickLabs tools collection

02PHP

Since Jul 26Pushed 1y ago2 watchersCompare

[ Source](https://github.com/KubrickLabs/database)[ Packagist](https://packagist.org/packages/kubricklabs/database)[ RSS](/packages/kubricklabs-database/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Database
========

[](#database)

Database is a simple and efficient database abstraction layer built on top of PDO. It provides easy-to-use methods for common database operations like CRUD operations, transaction management, and connection pooling.

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

[](#installation)

You can install the package via Composer. Run the following command:

```
composer require kubricklabs/database
```

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

Here's an example of how to use the Database package:

```
require 'vendor/autoload.php';

use Database\Database;

// Database connection details
$dsn = 'your_dsn';
$username = 'your_username';
$password = 'your_password';
$options = [];

// Get a Database instance
$db = Database::getInstance($dsn, $username, $password, $options);

// Example CRUD operations
$result = $db->select('SELECT * FROM your_table');
$db->insert('your_table', ['column1' => 'value1', 'column2' => 'value2']);
$db->update('your_table', ['column1' => 'new_value'], ['column2' => 'value2']);
$db->delete('your_table', ['column1' => 'new_value']);

// Transaction management
$db->beginTransaction();
// Perform multiple CRUD operations
$db->commit();
```

### Connection Pooling

[](#connection-pooling)

The library uses a connection pool to manage database connections efficiently. You don't need to manage the pool manually; the library takes care of it.

### Transaction Management

[](#transaction-management)

The `beginTransaction`, `commit`, and `rollBack` methods provide an easy way to manage database transactions.

```
$db->beginTransaction();

try {
    // Perform multiple operations
    $db->insert('your_table', ['column1' => 'value1']);
    $db->update('your_table', ['column1' => 'new_value'], ['column2' => 'value2']);
    $db->commit();
} catch (Exception $e) {
    $db->rollBack();
    echo "Failed: " . $e->getMessage();
}
```

Classes and Methods
-------------------

[](#classes-and-methods)

### Database

[](#database-1)

The main class that extends PDO and provides methods for CRUD operations and transaction management.

#### Methods

[](#methods)

- `select($query, $params = [], $fetchMode = PDO::FETCH_ASSOC)`
- `insert($table, $data)`
- `update($table, $data, $where)`
- `delete($table, $where)`
- `beginTransaction()`
- `commit()`
- `rollBack()`
- `getInstance($dsn, $username = null, $password = null, $options = null)`

### CRUDOperations

[](#crudoperations)

A helper class for performing CRUD operations.

#### Methods

[](#methods-1)

- `select($query, $params = [], $fetchMode = PDO::FETCH_ASSOC)`
- `insert($table, $data)`
- `update($table, $data, $where)`
- `delete($table, $where)`

### TransactionManager

[](#transactionmanager)

A helper class for managing transactions.

#### Methods

[](#methods-2)

- `beginTransaction()`
- `commit()`
- `rollBack()`

### ConnectionPool

[](#connectionpool)

A helper class for managing a pool of database connections.

#### Methods

[](#methods-3)

- `getConnection($dsn, $username, $password, $options)`
- `releaseConnection($connection)`

### ErrorHandler

[](#errorhandler)

A helper class for handling errors.

#### Methods

[](#methods-4)

- `handleError(PDOException $e)`

Contributing
------------

[](#contributing)

Please feel free to submit issues and pull requests.

License
-------

[](#license)

MIT License. See [LICENSE](LICENSE) for more information.

###  Health Score

14

—

LowBetter than 1% of packages

Maintenance26

Infrequent updates — may be unmaintained

Popularity2

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity18

Early-stage or recently created project

 Bus Factor1

Top contributor holds 66.7% 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.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/176553970?v=4)[KubrickLabs](/maintainers/KubrickLabs)[@KubrickLabs](https://github.com/KubrickLabs)

---

Top Contributors

[![IAmHal9000](https://avatars.githubusercontent.com/u/50555399?v=4)](https://github.com/IAmHal9000 "IAmHal9000 (12 commits)")[![KubrickLabs](https://avatars.githubusercontent.com/u/176553970?v=4)](https://github.com/KubrickLabs "KubrickLabs (6 commits)")

### Embed Badge

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

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

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k117.2M118](/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)
