packagek-kinzal/sql-semantics-mysql
MySQL statement models, SQL reconstruction, and schema binding for SQL Semantics
Namespaces§
| SqlSemantics\Platform\MySql | 5 classes 1 enum |
| SqlSemantics\Statement\Model\MySql\Choice | 230 enums |
| SqlSemantics\Statement\Model\MySql\Contract | 1 class |
| SqlSemantics\Statement\Model\MySql\Role | 1276 interfaces |
| SqlSemantics\Statement\Model\MySql\Value | 3448 classes |
Documents 1§
| SQL Semantics for MySQL | README.md |
README§
SQL Semantics for MySQL
License: MIT Docs PHP Version Ask DeepWiki
SQL Semantics for MySQL adds MySQL to SQL Semantics: the typed statement models of the official MySQL grammars and the MySQL rules for schema binding. Installing it also installs the shared SQL Semantics runtime, and Dialect::MySql selects MySQL 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. State declarations support all listed versions; SELECT binding with Binder requires MySQL 8.0 or later.
| Version | Version tag | Default |
|---|---|---|
| 5.6.51 | mysql-5.6.51 | |
| 5.7.44 | mysql-5.7.44 | |
| 8.0.44 | mysql-8.0.44 | |
| 8.1.0 | mysql-8.1.0 | |
| 8.2.0 | mysql-8.2.0 | |
| 8.3.0 | mysql-8.3.0 | |
| 8.4.7 | mysql-8.4.7 | Yes |
| 9.0.1 | mysql-9.0.1 | |
| 9.1.0 | mysql-9.1.0 |
Installation
composer require k-kinzal/sql-semantics-mysql
Usage
use SqlSemantics\Facade\Semantics;
use SqlSemantics\Platform\MySql\Dialect;
$statement = (new Semantics(Dialect::MySql))->analyze("INSERT INTO users (id, name) VALUES (1, 'Alice') ON DUPLICATE KEY UPDATE name = 'Alice'");
$statement->toString(); // "INSERT INTO users ( id , name ) VALUES( 1 , 'Alice' ) ON DUPLICATE KEY UPDATE name = 'Alice'"
See the SQL Semantics documentation for statement models and schema binding.
License
MIT License. See LICENSE for details.