{"repo":"sad-spirit/pg-builder","free":true,"listed":false,"github":"https://github.com/sad-spirit/pg-builder","clone":"git clone https://github.com/sad-spirit/pg-builder.git","description":"Query builder for Postgres backed by SQL parser","language":"PHP","stars":59,"topics":["postgresql","postgres","sql-parser","sql-builder","query-builder","query-parser","ast","php","sql"],"license":"BSD-2-Clause","category":"databases-storage","readme_excerpt":"sad spirit/pg builder This is a query builder for Postgres with a twist: it contains a partial 1 reimplementation of PostgreSQL's own query parser. This sets it aside from the usual breed of \"write-only\" query builders: Query is represented as an Abstract Syntax Tree quite similar to PostgreSQL's internal representation. Query parts can be added to the AST either as objects or as strings (that will be processed by Parser). Nodes can be removed and replaced in AST. AST can be analyzed and transformed, the package takes advantage of this to allow named parameters like :foo instead of standard PostgreSQL's positional parameters $1 and to infer parameters' types from SQL typecasts. Almost all syntax available for SELECT (and VALUES ) / INSERT / UPDATE / DELETE / MERGE in PostgreSQL 18 is supported, query being built is automatically checked for correct syntax. Substantial effort was made to optimise parsing, but not parsing is faster anyway, so there are means to cache parts of AST and the resultant query. Usage example the last echo statement will output something like if targeting Connection and something like if targeting PDO Installation Require the package with composer: pg builder requires at least PHP 8.2. Either native pgsql extension with pg wrapper package or PDO with pgsql support can be used to run the built queries. Minimum supported PostgreSQL version is 12. It is highly recommended to use PSR-6 compatible cache in production. Documentation For in-depth description ","default_branch":null,"files":null,"tree":[],"storefront":"/r/sad-spirit","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/sad-spirit/pg-builder/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}