Download the PHP package inclitoleo/dbmysql without Composer
On this page you can find all versions of the php package inclitoleo/dbmysql. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download inclitoleo/dbmysql
More information about inclitoleo/dbmysql
Files in inclitoleo/dbmysql
Package dbmysql
Short Description Simple, fast MySQL library for PHP. Raw SQL or query builder. Compatible with Laravel, CakePHP, and Symfony.
License GPL-3.0-or-later
Homepage https://github.com/inclitoleo/dbmysql
Informations about the package dbmysql
dbmysql
Simple, fast MySQL library for PHP. Write SQL when you want SQL. Use the builder only when it saves you time. Works beside Laravel, CakePHP, and Symfony — it does not replace Eloquent, Cake ORM, or Doctrine.
Package: inclitoleo/dbmysql
Namespace: Inclitoleo\Mysql\
PHP: >= 8.1
License: GPL-3.0-or-later
Existing MySqlClient callers keep working through a deprecated compatibility facade.
Install
Connect once
Register tables once at bootstrap. After that, pass a full query or use the builder — same connection.
Laravel, CakePHP, Symfony
Same QueryBuilder. Credentials come from the framework. Register tables once, then raw() or the builder.
Laravel
Auto-discovery registers QueryBuilder. Publish optional table config:
Uses config/database.php (DB_* / database.connections.mysql) by default.
Without auto-discovery:
CakePHP
Datasources.default in app.php / app_local.php (host, username, password, database, encoding) maps as-is.
Symfony
DATABASE_URL from .env:
Register tables in a compiler pass, a kernel boot listener, or a small decorator — same SchemaRegistry::register() as a plain PHP app.
Doctrine connection arrays work too: ConnectionConfig::fromArray($doctrineParams) (dbname, user, host, port, charset).
Values always go through native prepared statements (PDO::ATTR_EMULATE_PREPARES = false). Failures throw typed exceptions — v3 never echos errors.
Run SQL as you wrote it
You do not have to go through from() / where() / select(). raw() executes the statement as-is. Bind values with ?.
SELECT / WITH / SHOW / EXPLAIN return a list of objects. Other statements return the affected row count.
Join
There is no join builder. Pass the join in the SQL:
Tables named after FROM / JOIN / INTO / UPDATE must be registered. Table aliases (a, o) are ignored.
CTE
Same idea — the whole query, including WITH:
CTE names (recent) do not need to be registered. Base tables (account, orders) do.
Or compose the CTE with the builder and keep the outer query small:
Window function:
Query builder (optional)
Use it when chaining is shorter than writing SQL. Skip it when it is not.
Schema whitelist
Identifiers must match ^[a-zA-Z_][a-zA-Z0-9_]*$ and be registered (this applies to raw() too):
MySqlClient auto-registers identifiers that pass the charset check so v2 callers do not need a manual registry.
Transactions, batch, upsert, cursor pagination
Read / write split and ProxySQL
This library does not implement an in-process connection pool. For pooling under PHP-FPM, put ProxySQL or MySQL Router in front of MySQL and point ConnectionConfig at the proxy host/port. Persistent PDO (ConnectionConfig::$persistent / PersistentConnectionStrategy) is available when the process model benefits from it.
Optional PSR-3 logger:
Errors are logged at error with SQL and SQLSTATE when available.
Architecture
Entity mapper / Repository are opt-in. No Active Record, no lazy load.
Migrate from v2 (MySqlClient)
v2 code still works:
MySqlClient is deprecated. Internally it translates INCLITO* constants to ConnectionConfig and delegates to v3.
| v2 | v3 |
|---|---|
INCLITOHOST / INCLITOPORT |
ConnectionConfig(host, port) |
INCLITODBNAME / INCLITOUSER / INCLITOPWD |
database / username / password |
INCLITOTYPECONN |
persistent |
INCLITOBOOLCERT + CA/cert/key |
sslEnabled + SslConfig |
echo + false on error |
typed exceptions |
| concatenated identifiers | SchemaRegistry whitelist |
Host may still be localhost:3306. If INCLITOPORT is undefined, the port defaults to 3306 (or the :port suffix on the host).
Compat mode (default): catch v3 exceptions, echo the message, return false — same as v2.
Strict mode: define INCLITOSTRICT as true to rethrow:
Recommended replacement:
Connection constants (v2 facade)
Tests
PHPUnit 10 suites: unit, integration, security, regression.
Local MySQL for integration/regression/security payloads:
docker-compose.test.yml starts MySQL 8.4 with database dbmysql_test and seed tables account, orders, and logs.
Alternatively set DBMYSQL_TEST_DSN (mysql:host=127.0.0.1;port=3310;dbname=dbmysql_test) plus MYSQL_USER / MYSQL_PASSWORD.
Streaming memory tests honor DBMYSQL_STREAM_ROWS (default 1000) and DBMYSQL_STREAM_MEMORY_BYTES (default 8 MiB).
CI (GitHub Actions) runs PHP 8.1 / 8.2 / 8.3: lint, unit, integration against MySQL 8.4, security, regression, and v3 coverage (>= 90% on Connection, Query, Security, Exception, Mapper).
Debug
ConnectionConfig::$debug defaults to false. Failures always throw MysqlException; what changes is the public message.
debug |
getMessage() |
Use |
|---|---|---|
false (default, production) |
JSON only, e.g. {"code":500} |
Safe to return to the client |
true (local) |
Raw driver text, e.g. Query failed: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry '[email protected]' for key 'account.uq_account_email' |
Screen / logs while developing |
Public codes:
| Code | Meaning |
|---|---|
200 |
Success helper (ErrorCode::ok()). Not thrown; you emit it after a successful call. |
403 |
Identifier rejected or MySQL access denied |
404 |
Missing table/column, or empty firstOrFail() / findByIdOrFail() |
500 |
Query, constraint (duplicate key, FK), deadlock, or other operational failure |
SQL, bindings and PII stay off getMessage() unless debug is true. Keep debug off in production.
Exceptions
| Class | When |
|---|---|
MysqlException |
Base type for all library failures |
ConfigurationException |
Invalid config before PDO |
ConnectionException |
PDO connect failure |
QueryException |
SQL execution failure (getSql(), getBindings(), getSqlState()) |
InvalidIdentifierException |
Table/column/operator rejected |
NotFoundException |
Empty firstOrFail() / findByIdOrFail() ({"code":404}) |
TransactionException |
Failure inside transaction() after rollback |