PHPackages                             sinevia/php-library-sqldb - 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. sinevia/php-library-sqldb

ActiveLibrary

sinevia/php-library-sqldb
=========================

PHP Library for Working with SQL databases

v3.12.0(5y ago)486815proprietaryPHP

Since Jan 3Pushed 5y ago2 watchersCompare

[ Source](https://github.com/Sinevia/php-library-sqldb)[ Packagist](https://packagist.org/packages/sinevia/php-library-sqldb)[ Docs](http://github.com/sinevia/php-library-sqldb)[ RSS](/packages/sinevia-php-library-sqldb/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (30)Used By (5)

[![Gitpod Ready-to-Code](https://camo.githubusercontent.com/ec0084907bd5b3576af415a1e46cae636fbfa04da6bf9db6296eae3057a189f0/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f476974706f642d52656164792d2d746f2d2d436f64652d626c75653f6c6f676f3d676974706f64)](https://gitpod.io/#https://github.com/Sinevia/php-library-sqldb)

PHP Library SqlDB
=================

[](#php-library-sqldb)

PHP Library for working with SQL databases.

[![No Dependencies](https://camo.githubusercontent.com/e5650883bec05bec967678c8203c32b160b75c93b5b745c80bd9e6f25eb4a3db/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6e6f2d646570656e64656e636965732d737563636573732e737667)](https://camo.githubusercontent.com/e5650883bec05bec967678c8203c32b160b75c93b5b745c80bd9e6f25eb4a3db/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6e6f2d646570656e64656e636965732d737563636573732e737667)[![Build status](https://camo.githubusercontent.com/183148dd6f49bb02a15af6fa2cb586eecbf3eb43f24a78294fd472ddd7d3ae24/68747470733a2f2f6170692e7472617669732d63692e636f6d2f53696e657669612f7068702d6c6962726172792d73716c64622e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/Sinevia/php-library-sqldb)[![GitHub stars](https://camo.githubusercontent.com/97e604cadcb4f02c78b8693f560aaeaa811aa6c327c20418de73dc55060ab9a4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f53696e657669612f7068702d6c6962726172792d73716c64622e7376673f7374796c653d736f6369616c266c6162656c3d53746172266d61784167653d32353932303030)](https://GitHub.com/Sinevia/php-library-sqldb/stargazers/)[![HitCount](https://camo.githubusercontent.com/174b83234460353a6dc7ba702c6ed8bc962492182649349fde67c176d0e50307/687474703a2f2f686974732e6477796c2e696f2f53696e657669612f6261646765732e737667)](http://hits.dwyl.io/Sinevia/badges)

Features
--------

[](#features)

- MySQL, SQlite and SQLiteDB (SQLite in the cloud) supported
- Unified data types. The data types are developer orientated (string, text, integer, float, blob). These are then translated to the correct column type for the corresponding database.
- Fluent interface for building queries

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

[](#installation)

1. Via composer command line

```
composer require sinevia/php-library-sqldb
```

2. Via composer file:

Add the latest stable version to your composer file, and update via composer

```
"require": {
    "sinevia/php-library-sqldb": "3.8.0"
}
```

Data Types
----------

[](#data-types)

Data TypeMySQL Data TypeSQLite Data TypeSTRINGVARCHAR (255)TEXTTEXTLONG TEXTTEXTINTEGERBIG INTINTEGERFLOATDOUBLEREALBLOBLONG BLOBTEXTUsage
-----

[](#usage)

### 1) Creating a new database instance

[](#1-creating-a-new-database-instance)

```
// MySQL
$db = new Sinevia\SqlDB(array(
    'database_type'=>'mysql',
    'database_name'=>'db_name',
    'database_host'=>'db_host',
    'database_user'=>'db_user',
    'database_pass'=>'db_pass'
));

// SQLite (creating a new SQLite database, if it does not exist)
$db = new Sinevia\SqlDB(array(
    'database_type'=>'sqlite',
    'database_name'=>'db_name',
    'database_host'=>'db_host',
    'database_user'=>'db_user',
    'database_pass'=>'db_pass'
));

// SQLiteDB (SQLite in the cloud)
$db = new Sinevia\SqlDB(array(
    'database_type'=>'sqlitedb',
    'database_host'=>'sqlitedb_api_url',
    'database_pass'=>'sqlitedb_api_key'
));

// Using existing PDO instance
$db = new Sinevia\SqlDB($pdo);
```

### 2) Drop a database

[](#2-drop-a-database)

Depending on your database hosting this may or may not be supported

```
// Dropping a database
$db->drop();
```

### 3) Creating a new table

[](#3-creating-a-new-table)

```
// Check if table already exists?
if ($db->table("person")->exists() == false) {
    // Create table
    $db->table("person")
        ->column("Id", "INTEGER", "NOT NULL PRIMARY KEY AUTO_INCREMENT")
        ->column("FirstName", "STRING")
        ->column("LastName", "STRING")
        ->create();
}
```

### 3) Drop a table

[](#3-drop-a-table)

```
// Dropping a table
$isOk = $db->table("person")->drop();
```

### 3) Inserting rows

[](#3-inserting-rows)

```
$isOk = $db->table('person')->insert([
    'FirstName' => 'Peter',
    'LastName' => 'Pan',
]);

// Getting the new autoincremented ID
$personId = $db->lastInsertId();
```

### 4) Selecting rows

[](#4-selecting-rows)

```
//Selects all the rows from the table
$rows = $db->table("person")->select();

// Selects the rows where the column NAME is different from Peter, in descending order
$rows = $db->table("person")
    ->where("Name", "!=", "Peter")
    ->orderby("Name","desc")
    ->select();
```

### 5) Updating rows

[](#5-updating-rows)

```
// Delete row by ID
$isOk = $db->table("person")
    ->where("Id", "==", "1")
    ->update([
        'LastName' => 'Voldemort'
    ]);
```

### 5) Deleting rows

[](#5-deleting-rows)

```
// Delete row by ID
$isOk = $db->table("person")
    ->where("Id", "==", "1")
    ->delete();

// Delete all rows in the table
$isOk = $db->table("person")->delete();
```

Helper Functions
----------------

[](#helper-functions)

### 1) Generating UUIDs

[](#1-generating-uuids)

```
$uuid = Sinevia\SqlDB::uuid();
```

### 2) Generating HUIDs

[](#2-generating-huids)

HUIDs are human friendly unique identifiers, which are date based.

```
$uid20 = Sinevia\SqlDB::uid(); // 20 digits default
$uid32 = Sinevia\SqlDB::uid(32); // 32 digits
```

Related Projects
================

[](#related-projects)

- [Cache](https://github.com/Sinevia/php-library-sqldb-cache)
- [Monolog](https://github.com/Sinevia/php-library-sqldb-monolog)
- [Tasks](https://github.com/Sinevia/php-library-sqldb-tasks)

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 88.4% 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 ~32 days

Recently: every ~87 days

Total

28

Last Release

2161d ago

Major Versions

v1.0.1 → v2.0.02018-08-20

v2.9.0 → v3.0.02019-06-13

### Community

Maintainers

![](https://www.gravatar.com/avatar/d935723d26f92caa8fb66c4a44cf1995c488734b54e36f5b616ac290a109ab59?d=identicon)[sinevia](/maintainers/sinevia)

---

Top Contributors

[![Sinevia](https://avatars.githubusercontent.com/u/3450815?v=4)](https://github.com/Sinevia "Sinevia (130 commits)")[![lesichkovm](https://avatars.githubusercontent.com/u/7744963?v=4)](https://github.com/lesichkovm "lesichkovm (17 commits)")

---

Tags

phplibrarysineviasqldb

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/sinevia-php-library-sqldb/health.svg)

```
[![Health](https://phpackages.com/badges/sinevia-php-library-sqldb/health.svg)](https://phpackages.com/packages/sinevia-php-library-sqldb)
```

PHPackages © 2026

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