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

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

kirameki/database
=================

Database library for Kirameki Framework

13PHPCI failing

Since Feb 1Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/kirameki-php/database)[ Packagist](https://packagist.org/packages/kirameki/database)[ RSS](/packages/kirameki-database/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Database library for PHP
========================

[](#database-library-for-php)

[![Test](https://github.com/kirameki-php/database/actions/workflows/test.yml/badge.svg)](https://github.com/kirameki-php/database/actions/workflows/test.yml/badge.svg)[![codecov](https://camo.githubusercontent.com/a78a910247644104d5190ebd82cf23239d05dbcbedc3c372ad77802dce25b59c/68747470733a2f2f636f6465636f762e696f2f67682f6b6972616d656b692d7068702f64617461626173652f6272616e63682f6d61696e2f67726170682f62616467652e7376673f746f6b656e3d315056384642344f344f)](https://codecov.io/gh/kirameki-php/database)[![GitHub](https://camo.githubusercontent.com/bdbce0d959fe6553dc9161aa4bcbd722f9d0fcaa5eceea3fdf6808c85e5ca891/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6b6972616d656b692d7068702f6461746162617365)](https://camo.githubusercontent.com/bdbce0d959fe6553dc9161aa4bcbd722f9d0fcaa5eceea3fdf6808c85e5ca891/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6b6972616d656b692d7068702f6461746162617365)

Prerequisites
-------------

[](#prerequisites)

- PHP 8.3+

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

[](#installation)

```
composer require kirameki/database

```

Isolation level
===============

[](#isolation-level)

Kirameki will set the isolation level to `SERIALIZABLE` for all transactions. Lower isolation level is [risky and is not worth the small gain in performance for most apps](https://fauna.com/blog/introduction-to-transaction-isolation-levels#what-isolation-level-should-you-choose). You can change the isolation level by passing `IsolationLevel` to a `transaction(...)`.

SQL Database Nuances
====================

[](#sql-database-nuances)

Numeric (Decimal) Type Handling
-------------------------------

[](#numeric-decimal-type-handling)

DatabaseDescriptionSQLiteValue is converted to INTEGER or REAL. Only the first 15 significant decimal digits of the number are preserved. You may lose precision without knowing it. ([Docs](https://www.sqlite.org/datatype3.html#type_affinity))PostgreSQLUp to 131072 digits before the decimal point; Up to 16383 digits after the decimal point. Can be specified by user. ([Docs](https://www.postgresql.org/docs/current/datatype-numeric.html))MySQLPrecision can have range 1 to 65. Scale can be set from 0 to 30. Can be specified by user. ([Docs](https://dev.mysql.com/doc/refman/en/precision-math-decimal-characteristics.html))MariaDB*Same as MySQL*In this framework, MySQL and MariaDB will use `DECIMAL(65, 30)` by default, while PostgreSQL will use `NUMERIC` without precision or scale.

Session Level Timeout
---------------------

[](#session-level-timeout)

DatabaseSupportedDescriptionQuerySQLite╳No option exists.PostgreSQL◯Works. ([Docs](https://www.postgresql.org/docs/current/runtime-config-client.html#GUC-STATEMENT-TIMEOUT))`SET statement_timeout={milliseconds}`MySQL△Only works for SELECT. ([Docs](https://dev.mysql.com/doc/refman/en/server-system-variables.html#sysvar_max_execution_time))`SET SESSION max_execution_time={milliseconds}`MariaDB◯Works. ([Docs](https://mariadb.com/kb/en/server-system-variables/#max_statement_time))`SET max_statement_time={seconds}`Isolation Level Changes Per Transaction
---------------------------------------

[](#isolation-level-changes-per-transaction)

DatabaseSupportedDescriptionQuerySQLite╳Only supports read\_uncommitted per connection via `PRAGMA`.PostgreSQL◯Works. Must call within the open transaction. ([Docs](https://www.postgresql.org/docs/current/sql-set-transaction.html))`SET TRANSACTION {mode}`MySQL◯Works. Must call before BEGIN. ([Docs](https://dev.mysql.com/doc/en/set-transaction.html))`SET TRANSACTION ISOLATION LEVEL {mode}`MariaDB◯*Same as MySQL* ([Docs](https://mariadb.com/kb/en/set-transaction/))*Same as MySQL*Upsert
------

[](#upsert)

DatabaseSupportedDescriptionQuerySQLite◯Works. ([Docs](https://www.sqlite.org/lang_upsert.html))`INSERT INTO … ON CONFLICT … DO UPDATE SET…`PostgreSQL◯Works. ([Docs](https://www.postgresql.org/docs/current/sql-insert.html))`INSERT INTO … ON CONFLICT … DO UPDATE SET…`MySQL△Does not work as expected on tables with multiple unique indexes.
Use with caution. Read the docs carefully. ([Docs](https://dev.mysql.com/doc/en/insert-on-duplicate.html))`INSERT INTO … ON DUPLICATE KEY UPDATE …`MariaDB△*Same as MySQL* ([Docs](https://mariadb.com/kb/en/insert-on-duplicate-key-update))*Same as MySQL*Affected Row Count
------------------

[](#affected-row-count)

SELECT statements usually return `0` when calling `QueryResult::getAffectedRowCount()`, but when you run a SELECT statement using `RawStatement`, the method will give different results depending on the database you use. This is stated in the [PHP PDO documentation](https://www.php.net/manual/en/pdostatement.rowcount.php).

For example, running the following statement will return different results for different databases.

Query:

```
SELECT 1 as a;
```

DatabaseResultSQLite0MySQL1CURRENT\_TIMESTAMP
------------------

[](#current_timestamp)

SQLite's `CURRENT_TIMESTAMP` returns the time in UTC, while MySQL and PostgreSQL return the time in the server's timezone. This library uses `DATETIME('now', 'localtime')` for SQLite to get the time in the system timezone instead. This is still not perfect because the system timezone is not always the same as the PHP's and `date_default_timezone_set()`does not affect the timezone for SQLite.

SUM() function
--------------

[](#sum-function)

MySQL will return the sum as DECIMAL represented as string. This is because SUM can be larger than PHP's integer limit. In SQLite the sum is returned as an integer/float and will return an error if integer overflows.

Note

On a related note, SUM will return NULL if no rows are found. This is the same for all databases.

NULL Ordering
-------------

[](#null-ordering)

SQLite and MySQL will treat NULL as the lowest value when ordering, while PostgreSQL will treat NULL as the highest value.

License
-------

[](#license)

This is an open-sourced software licensed under the [MIT License](LICENSE).

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance54

Moderate activity, may be stable

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity12

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/02fd797054dcc2ad8fd9e01dba848d8bb50f00a4748e681a6c57860c22217814?d=identicon)[taka-oyama](/maintainers/taka-oyama)

---

Top Contributors

[![taka-oyama](https://avatars.githubusercontent.com/u/748854?v=4)](https://github.com/taka-oyama "taka-oyama (541 commits)")

### Embed Badge

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

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

###  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)[ramsey/uuid-doctrine

Use ramsey/uuid as a Doctrine field type.

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

Reliese Components for Laravel Framework code generation.

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

Laravel Userstamps provides an Eloquent trait which automatically maintains `created\_by` and `updated\_by` columns on your model, populated by the currently authenticated user in your application.

7511.7M13](/packages/wildside-userstamps)

PHPackages © 2026

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