Download the PHP package k-kinzal/ztd-query-sqlite without Composer
On this page you can find all versions of the php package k-kinzal/ztd-query-sqlite. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download k-kinzal/ztd-query-sqlite
More information about k-kinzal/ztd-query-sqlite
Files in k-kinzal/ztd-query-sqlite
Package ztd-query-sqlite
Short Description SQLite platform support for ZTD Query
License MIT
Informations about the package ztd-query-sqlite
ZTD Query SQLite
SQLite platform support for ZTD Query PHP. Provides SQL parsing, classification, rewriting, and schema management for SQLite.
Overview
This package implements the SQLite-specific logic for ZTD (Zero Table Dependency) query transformation. It handles:
- SQL Parsing - Parse SQLite statements using a built-in regex-based parser
- Query Classification - Classify queries as READ, WRITE_SIMULATED, or DDL_SIMULATED
- CTE Rewriting - Transform SELECT queries to use CTE-shadowed fixture data
- Result Select Query - Convert INSERT/UPDATE/DELETE/REPLACE into SELECT queries returning affected rows
- Schema Management - Reflect and track SQLite table definitions via
sqlite_masterandPRAGMAqueries - Error Classification - Identify SQLite-specific error codes for unknown schema detection
This package is used internally by the PDO adapter, but can also be used directly for custom adapter implementations.
Requirements
- PHP 8.1 or higher
- k-kinzal/ztd-query-php (core)
Installation
Usage
Creating a SQLite Session
SqliteSessionFactory is the main entry point. It creates a fully configured Session instance for SQLite:
The factory automatically:
- Reflects the database schema via
sqlite_masterandPRAGMAqueries - Sets up the SQL parser, query guard, and all transformers
- Configures the shadow store for virtual write tracking
Query Classification
SqliteQueryGuard classifies SQL statements into query kinds:
SQL Rewriting
SqliteRewriter transforms SQL statements for ZTD execution:
Error Classification
SqliteErrorClassifier identifies SQLite error codes related to unknown schemas:
Architecture
SQL Support
Fully Supported
- SELECT: All clauses including JOIN, GROUP BY, HAVING, ORDER BY, LIMIT, OFFSET, UNION, INTERSECT, EXCEPT, subqueries, CTEs, window functions, DISTINCT, VALUES
- INSERT: VALUES, SELECT, DEFAULT VALUES, ON CONFLICT (upsert)
- REPLACE: VALUES, SELECT
- UPDATE: Single-table with WHERE, ORDER BY/LIMIT
- DELETE: Single-table with WHERE, ORDER BY/LIMIT
- DDL: CREATE TABLE, ALTER TABLE, DROP TABLE (virtual schema)
- WITH: CTE and recursive CTE
Unsupported
- Triggers, views, virtual tables
- Database operations (ATTACH, DETACH)
- VACUUM, ANALYZE, REINDEX
- PRAGMA statements
Development
License
MIT License. See LICENSE for details.