- PHP 8.3+
composer require kirameki/database
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.
You can change the isolation level by passing IsolationLevel
to a transaction(...)
.
Database | Supported | Description | Query |
---|---|---|---|
SQLite | ╳ | No option exists. | |
PostgreSQL | ◯ | Works. (Docs) | SET statement_timeout={milliseconds} |
MySQL | △ | Only works for SELECT. (Docs) | SET SESSION max_execution_time={milliseconds} |
MariaDB | ◯ | Works. (Docs) | SET max_statement_time={seconds} |
Database | Supported | Description | Query |
---|---|---|---|
SQLite | ╳ | Only supports read_uncommitted per connection via PRAGMA . |
|
PostgreSQL | ◯ | Works. Must call within the open transaction. (Docs) | SET TRANSACTION {mode} |
MySQL | ◯ | Works. Must call before BEGIN. (Docs) | SET TRANSACTION ISOLATION LEVEL {mode} |
MariaDB | ◯ | Same as MySQL (Docs) | Same as MySQL |
Database | Supported | Description | Query |
---|---|---|---|
SQLite | ◯ | Works. (Docs) | INSERT INTO … ON CONFLICT … DO UPDATE SET… |
PostgreSQL | ◯ | Works. (Docs) | 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) |
INSERT INTO … ON DUPLICATE KEY UPDATE … |
MariaDB | △ | Same as MySQL (Docs) | Same as MySQL |
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.
For example, running the following statement will return different results for different databases.
Query:
SELECT 1 as a;
Database | Result |
---|---|
SQLite | 0 |
MySQL | 1 |
This is an open-sourced software licensed under the MIT License.