Last updated: 2026-10-25
CHAIN YOUR QUERIES, NOT YOUR STRINGS!
A PHP MySQL client with chainable query building, read-write connection targets, and slow query logging
composer require pardnchiu/mysql-cli· Documentation
- Chainable Query Building — Chain table, select, join, where, groupBy, orderBy, and limit to build SQL without hand-concatenated strings.
- Read-Write Connection Targets — Read and write databases each get their own set of environment variables, chosen by an argument or the read / write methods.
- Typed Parameter Binding — Every value goes through a prepared statement and binds as integer, boolean, null, or string to prevent SQL injection.
- Connection Retry and Slow Query Logging — Failed connections retry three times with exponential backoff, and queries over 20 ms are written to error_log.
- Pagination Total in One Query — A window function attaches the total row count to the same query, so pagination skips the second COUNT.
graph TB
A[Caller] --> B[SQL::table / read / write]
ENV[DB_READ_* / DB_WRITE_*] --> C[PDO connection + retry]
B --> C
B --> D[Query builder state]
D --> E[SQL assembly]
E --> F[query: prepare + bind]
C --> F
F --> G[(MySQL)]
F --> H[Slow query error_log]
This project is licensed under the MIT LICENSE.
Just open an issue to share an idea.
©️ 2024 邱敬幃 Pardn Chiu