Download the PHP package k-kinzal/ztd-query-php without Composer
On this page you can find all versions of the php package k-kinzal/ztd-query-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Table of contents
Download k-kinzal/ztd-query-php
More information about k-kinzal/ztd-query-php
Files in k-kinzal/ztd-query-php
Download k-kinzal/ztd-query-php
More information about k-kinzal/ztd-query-php
Files in k-kinzal/ztd-query-php
Vendor k-kinzal
Package ztd-query-php
Short Description Zero Table Dependencies query layer for PHP
License MIT
Package ztd-query-php
Short Description Zero Table Dependencies query layer for PHP
License MIT
Please rate this library. Is it a good library?
Informations about the package ztd-query-php
ZTD Query PHP
A Zero Table Dependency testing library for PHP 8.1+ that enables SQL unit testing without modifying physical databases.
Overview
ZTD Query PHP wraps PDO to intercept and transform SQL queries using CTE (Common Table Expression) shadowing. This allows you to:
- Test SQL queries against fixture data without migrations, data seeding, or cleanup
- Use the real MySQL engine for query execution (not mocks)
- Run tests in parallel with complete isolation
- Treat SQL as pure functions: input (fixtures) -> output (results)
How It Works
CTE Shadowing - Table references in SELECT queries are replaced with CTEs containing your fixture data:
Result Select Query - INSERT/UPDATE/DELETE statements are converted to SELECT queries that return the affected rows:
Requirements
- PHP 8.1 or higher
- MySQL 5.6 - 9.1
- PDO extension
Installation
Usage
Basic Example
Wrapping Existing PDO
Testing Write Operations
Enabling/Disabling ZTD Mode
Configuration
Configuration Options
| Option | Values | Description |
|---|---|---|
unsupportedBehavior |
Ignore, Notice, Exception |
Default behavior when unsupported SQL is executed |
unknownSchemaBehavior |
Passthrough, Exception |
Behavior when unknown table is referenced |
behaviorRules |
array<string, UnsupportedSqlBehavior> |
Per-pattern behavior overrides (first match wins) |
SQL Support
Fully Supported
- SELECT: All clauses including JOIN, GROUP BY, HAVING, ORDER BY, LIMIT, UNION, subqueries, CTEs, window functions
- INSERT: VALUES, SELECT, ON DUPLICATE KEY UPDATE, IGNORE
- REPLACE
- UPDATE: Single/multi-table with ORDER BY/LIMIT
- DELETE: Single/multi-table with ORDER BY/LIMIT
- TRUNCATE
- DDL: CREATE TABLE, ALTER TABLE, DROP TABLE (virtual schema)
- WITH: CTE and recursive CTE
Ignored (No-op)
- Transaction control: BEGIN, COMMIT, ROLLBACK, SAVEPOINT
Unsupported
- Stored procedures, triggers, functions, views
- Database/schema operations
- User/permission management
- Server operations (FLUSH, RESET, etc.)
Development
License
MIT License. See LICENSE for details.
All versions of ztd-query-php with dependencies
PHP Build Version
Package Version
Requires
php Version
^8.1
The package k-kinzal/ztd-query-php contains the following files
Loading the files please wait ...