PHPackages                             thipages/quickdb - 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. thipages/quickdb

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

thipages/quickdb
================

Quick SQLite/MySql database sql creation builder

v0.5.1(5y ago)23311MITPHP

Since Aug 21Pushed 5y ago1 watchersCompare

[ Source](https://github.com/thipages/quickdb)[ Packagist](https://packagist.org/packages/thipages/quickdb)[ RSS](/packages/thipages-quickdb/feed)WikiDiscussions master Synced yesterday

READMEChangelog (3)Dependencies (2)Versions (9)Used By (1)

quickdb
=======

[](#quickdb)

Quick SQLite and MySql/MariaDB database sql creation builder

### Installation

[](#installation)

**composer** require thipages\\quickdb

### Dependency

[](#dependency)

[quicksql](https://github.com/thipages/quicksql)

### QDb class API

[](#qdb-class-api)

```
    // Creates sql database creation statements
    create($definition, $options=[]):Array
    // Creates insert/update/delete sql statements
    insert($tableName, $keyValues):string
    update($tableName, $keyValues, $where):string
    delete($tableName, $keyValues, $where):string
```

**Primary keys** are automatically created as `id` field name

**Foreign keys** are automatically indexed

**`$defintion`** is an associative array &lt;tableName,fieldDefinition&gt; fieldDefinition follows SQLite definition rules but supports shortcuts for indexes and foreign keys

- `#INDEX` or `#UNIQUE` to add an index (unique) to the field,
- `#FK_parentTable` to associate the field to the primary key of its parent table (foreign key)

**`$options`** is an associated array for customization by merging with default

- `primarykey : string` defines the primary key common to all tables, default : `id INTEGER PRIMARY KEY AUTOINCREMENT`
- `prefield : boolean` (default:`false`). If true : all fields are prefixed by table name
- `omnifields : array` defines fields present in all tables, default:

```
// For SQLite
[
    "created_at INTEGER  not null default (strftime('%s','now'))",
    "modified_at INTEGER  not null default (strftime('%s','now'))"
]
// For MySql/MariaDB
[
    "created_at TIMESTAMP  not null default CURRENT_TIMESTAMP",
    "modified_at TIMESTAMP not null default CURRENT_TIMESTAMP ON UPDATE current_timestamp"
                ]

```

Note 1 : if `modified_at` definition is present in omnifields options, it will be automatically updated on `update`

Note 2 : `strftime('%s','now')` stores UTC unixtime (sqlite)

#### Example

[](#example)

```
$db=new QDb();
$db->create(
    [
        // MySql : VARCHAR(xx) is mandatory for MySql indexation
        // MariaDB : TEXT would be ok
        // SQLite : use TEXT instead - Equivalent to VARCHAR(X)
        'user'=>'name VARCHAR(10) #INDEX',
        'message'=>[
            'content TEXT',
            'userId INTEGER NOT NULL #FK_user',
            'category TEXT #UNIQUE'
        ]
        ]
);
/*
For Sqlite
Array
(
    [0] => PRAGMA foreign_keys=OFF;
    [1] => DROP TABLE IF EXISTS user;
    [2] => CREATE TABLE user (id INTEGER PRIMARY KEY AUTOINCREMENT,name VARCHAR(10),created_at INTEGER not null default (strftime('%s','now')),modified_at INTEGER not null default (str
ftime('%s','now')));
    [3] => DROP INDEX IF EXISTS user_name_idx;
    [4] => CREATE  INDEX user_name_idx ON user (name);
    [5] => DROP TABLE IF EXISTS message;
    [6] => CREATE TABLE message (id INTEGER PRIMARY KEY AUTOINCREMENT,content TEXT,userId INTEGER NOT NULL ,category TEXT,created_at INTEGER not null default (strftime('%s','now')),mod
ified_at INTEGER not null default (strftime('%s','now')),FOREIGN KEY(userId) REFERENCES user(id));
    [7] => DROP INDEX IF EXISTS message_category_idx;
    [8] => CREATE UNIQUE INDEX message_category_idx ON message (category);
    [9] => DROP INDEX IF EXISTS message_userId_idx;
    [10] => CREATE INDEX message_userId_idx ON message (userId);
    [11] => PRAGMA foreign_keys=ON;
)

For Mysql/MariaDB - varchar(10) for user name for compatibility
Array
(
    [0] => SET FOREIGN_KEY_CHECKS=0;
    [1] => DROP TABLE IF EXISTS user;
    [2] => CREATE TABLE user (id INTEGER PRIMARY KEY AUTO_INCREMENT,name VARCHAR(10),created_at TIMESTAMP not null default CURRENT_TIMESTAMP,modified_at TIMESTAMP not null default CURRENT_TIMESTAMP ON UPDATE current_timestamp);
    [3] => CREATE  INDEX user_name_idx ON user (name);
    [4] => DROP TABLE IF EXISTS message;
    [5] => CREATE TABLE message (id INTEGER PRIMARY KEY AUTO_INCREMENT,content TEXT,userId INTEGER NOT NULL ,category TEXT,created_at TIMESTAMP not null default CURRENT_TIMESTAMP,modified_at TIMESTAMP not null default CURRENT_TIMESTAMP ON UPDATE current_timestamp,FOREIGN KEY(userId) REFERENCES user(id));
    [6] => CREATE UNIQUE INDEX message_category_idx ON message (category);
    [7] => CREATE INDEX message_userId_idx ON message (userId);
    [8] => SET FOREIGN_KEY_CHECKS=1;
)
*/
```

###  Health Score

25

—

LowBetter than 35% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity50

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

Every ~43 days

Recently: every ~75 days

Total

8

Last Release

1839d ago

### Community

Maintainers

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

---

Top Contributors

[![thipages](https://avatars.githubusercontent.com/u/130309?v=4)](https://github.com/thipages "thipages (25 commits)")

---

Tags

creationdatabaseforeign-keysindexphpquicksqlitedatabasesqliteindexcreationquickforeign-keys

### Embed Badge

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

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

###  Alternatives

[doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database schema introspection and management.

9.7k605.0M6.8k](/packages/doctrine-dbal)[catfan/medoo

The lightweight PHP database framework to accelerate development

5.0k1.6M204](/packages/catfan-medoo)[scienta/doctrine-json-functions

A set of extensions to Doctrine that add support for json query functions.

58825.9M54](/packages/scienta-doctrine-json-functions)[nette/database

💾 Nette Database: layer with a familiar PDO-like API but much more powerful. Building queries, advanced joins, drivers for MySQL, PostgreSQL, SQLite, MS SQL Server and Oracle.

5687.0M262](/packages/nette-database)[usmanhalalit/pixie

A lightweight, expressive, framework agnostic query builder for PHP.

6882.2M16](/packages/usmanhalalit-pixie)[dibi/dibi

Dibi is Database Abstraction Library for PHP

5014.0M134](/packages/dibi-dibi)

PHPackages © 2026

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