mini\Database\PartialQuery final class

Documentation

Immutable query builder for composable SQL queries

Inheritance

Implements: mini\Database\ResultSetInterface mini\Table\Contracts\MutableTableInterface Stringable Traversable Countable JsonSerializable IteratorAggregate mini\Table\Contracts\SetInterface mini\Table\Contracts\TableInterface

Uses Traits: mini\Table\Utility\TablePropertiesTrait

Properties (14)

private Closure $executor
private string $baseSql

Original SQL string - used directly for fast path when AST is null

private array $originalParams

Original params - used directly for fast path when AST is null

Single AST root - the source of truth for query structure

private bool $astIsPrivate

Whether this instance owns its AST (for copy-on-write)

private bool $selectCalled

Track if select/columns was called (for has() validation)

private ?array $availableColumns

Available columns after explicit projection (null = unrestricted)

private ?Closure $hydrator
private ?string $entityClass
private array|false $entityConstructorArgs
private ?Closure $loadCallback
private ?array $columnCache
private array $props

Methods (88)

Documentation missing

Ensure AST exists (lazy parsing)

Bind parameter values to PlaceholderNodes in an AST

Ensure AST is mutable (copy-on-write)

Get the innermost SelectStatement for modification

Wrap an AST node in a SELECT * FROM (...) AS alias

Clone handler - mark AST as shared for copy-on-write

Borrow AST for embedding into another query

Get the AST representation of this query

Get SQL and parameters for execution

Create a PartialQuery from SQL

Create a PartialQuery from any TableInterface

Get source table info from AST (computed on demand)

Check if this is a single-table query (supports UPDATE/DELETE)

Get the underlying source table for UPDATE/DELETE operations

Use an entity class for hydration

Set a callback to be called after each entity is hydrated

Use a custom hydrator closure

Add a WHERE clause with raw SQL

AND a predicate to the WHERE clause (internal helper)

Return a query that matches no rows (WHERE 1=0)

Create column identifier from name (handles table.column)

Create a placeholder with value pre-bound

Add WHERE column = value clause (NULL -> IS NULL)

Documentation missing

Documentation missing

Documentation missing

Documentation missing

Add WHERE column IN (...) clause

Add WHERE column LIKE pattern clause

Union with another query (OR semantics, deduplicated)

Difference from another query (NOT IN semantics)

Merge CTEs from another query into this one

Get the inner query (without CTE wrapper)

Find a CTE by name in the AST

Ensure AST is wrapped in a WithStatement (for adding CTEs)

Add a PartialQuery as a named CTE (Common Table Expression)

Set SELECT clause (wraps query with new projection)

Internal: wrap query with new SELECT clause

Extract column references from an expression AST

Get the output name of a column node

Project to specific columns (TableInterface method)

Check if value(s) exist in the table (SetInterface method)

Set ORDER BY clause (overwrites previous)

Set LIMIT (can only narrow, never expand)

Set OFFSET (additive, stays within window)

Create a barrier - wrap current query as subquery (internal)

Return distinct rows only

Alias this table/query

Get SelectStatement for reading (without triggering copy-on-write)

Check if query has pagination (LIMIT or OFFSET)

Fetch first row or null

Fetch first column from all rows

Fetch first column of first row

Get all rows as array

JSON serialize - returns all rows

Transform each row using a closure

Filter rows using a closure

Count rows that would be returned by iteration

Strip ORDER BY from an AST (mutates)

Iterator over results (streaming)

Get WHERE clause SQL and parameters, for DELETE/UPDATE

Test if a row matches the query's WHERE conditions

Get LIMIT value (for DELETE/UPDATE implementations)

Get current offset

Check if any rows exist

Get column definitions

Get all column definitions (including hidden columns)

Fetch column definitions from schema or AST

Fetch column definitions from database schema

Extract column definitions from explicit SELECT list

Map SQL data type string to ColumnType

OR predicate support

Convert a Predicate to AST expression

Convert a single condition to AST

Convert a PHP value to a LiteralNode

Create a bound placeholder (named parameter that's already resolved)

Load a single row by ID

Get CTE (Common Table Expression) prefix for DELETE/UPDATE

Debug information for var_dump/print_r

Convert to string for logging/debugging

Insert a new row into the underlying table

Update rows matching this query

Delete rows matching this query

Combine this query's constraints with a filter query

Get a property value

Check if a property exists (including null values)

Return table with property set

Source

src/Database/PartialQuery.php:45-2296