documentSQL Semantics for PostgreSQL
SQL Semantics for PostgreSQL
License: MIT Docs PHP Version Ask DeepWiki
SQL Semantics for PostgreSQL adds PostgreSQL to SQL Semantics: the typed statement models of the official PostgreSQL grammars and the PostgreSQL rules for schema binding. Installing it also installs the shared SQL Semantics runtime, and Dialect::PostgreSql selects PostgreSQL in the runtime's Semantics, Schema, and Binder. No database connection is needed.
Requirements
- PHP 8.1+ with the zlib extension
Support Syntax
The following grammar versions are supported. Pass the version tag as the second argument of Semantics or the third argument of Schema; omitting it uses the default.
| Version | Version tag | Default |
|---|---|---|
| 17.2 | pg-17.2 | Yes |
Installation
composer require k-kinzal/sql-semantics-postgres
Usage
use SqlSemantics\Facade\Semantics;
use SqlSemantics\Platform\PostgreSql\Dialect;
$statement = (new Semantics(Dialect::PostgreSql))->analyze("INSERT INTO users (id, name) VALUES (1, 'Alice') RETURNING id");
$statement->toString(); // "INSERT INTO users ( id , name ) VALUES( 1 , 'Alice' ) RETURNING id"
See the SQL Semantics documentation for statement models and schema binding.
License
MIT License. See LICENSE for details.