{"id":45753414,"url":"https://github.com/jardissupport/dbquery","last_synced_at":"2026-06-12T07:01:32.443Z","repository":{"id":336378399,"uuid":"1146687907","full_name":"jardisSupport/dbquery","owner":"jardisSupport","description":"Fluent SQL query builder with CTEs, window functions, subqueries, and JSON support for MySQL, MariaDB, PostgreSQL, and SQLite","archived":false,"fork":false,"pushed_at":"2026-06-11T19:16:07.000Z","size":209,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-11T21:08:57.128Z","etag":null,"topics":["domain-driven-design","jardis","php","query-builder","sql","sql-builder"],"latest_commit_sha":null,"homepage":"https://jardis.io","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jardisSupport.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":"support/README.md","governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-31T14:13:35.000Z","updated_at":"2026-06-11T19:16:02.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/jardisSupport/dbquery","commit_stats":null,"previous_names":["jardissupport/dbquery"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/jardisSupport/dbquery","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jardisSupport%2Fdbquery","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jardisSupport%2Fdbquery/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jardisSupport%2Fdbquery/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jardisSupport%2Fdbquery/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jardisSupport","download_url":"https://codeload.github.com/jardisSupport/dbquery/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jardisSupport%2Fdbquery/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34232790,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-12T02:00:06.859Z","response_time":109,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["domain-driven-design","jardis","php","query-builder","sql","sql-builder"],"created_at":"2026-02-25T19:19:27.217Z","updated_at":"2026-06-12T07:01:32.428Z","avatar_url":"https://github.com/jardisSupport.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Jardis DbQuery\n\n![Build Status](https://github.com/jardisSupport/dbquery/actions/workflows/ci.yml/badge.svg)\n[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE.md)\n[![PHP Version](https://img.shields.io/badge/PHP-%3E%3D8.2-777BB4.svg)](https://www.php.net/)\n[![PHPStan Level](https://img.shields.io/badge/PHPStan-Level%208-brightgreen.svg)](phpstan.neon)\n[![PSR-12](https://img.shields.io/badge/Code%20Style-PSR--12-blue.svg)](phpcs.xml)\n[![Coverage](https://img.shields.io/badge/Coverage-96.65%25-brightgreen.svg)](https://github.com/jardisSupport/dbquery)\n\n\u003e Part of **[Jardis](https://jardis.io)** — the Domain-Driven Design platform for PHP. You model your domain; Jardis generates the production-ready hexagonal code (DTOs, Command/Query handlers, repositories, persistence). This package is part of the open-source foundation that generated code runs on.\n\nA fluent SQL query builder for PHP that generates dialect-aware SQL for MySQL, MariaDB, PostgreSQL, and SQLite. Full support for CTEs, window functions, subqueries, JSON columns, and prepared statements. SQL injection protection built in.\n\n---\n\n## Features\n\n- **Dialect-Aware SQL** — generates correct syntax for MySQL, MariaDB, PostgreSQL, and SQLite from a single builder\n- **CTEs** — `with()` and `withRecursive()` for common table expressions\n- **Window Functions** — `selectWindow()`, `window()`, and `selectWindowRef()` for analytics queries\n- **Subqueries** — subqueries in FROM, JOIN constraints, SELECT columns, and WHERE EXISTS / NOT EXISTS\n- **JSON Column Support** — `whereJson()`, `andJson()`, `orJson()`, `havingJson()` for structured JSON field conditions\n- **Union / Union All** — `union()` and `unionAll()` compose multiple SELECT statements\n- **Prepared Statements** — `sql($dialect, prepared: true)` returns a `DbPreparedQueryInterface` with bound parameters\n- **SQL Injection Validation** — bracket and expression validation built into `sql()` before generation\n- **INSERT Conflict Handling** — `DbInsert` supports ON DUPLICATE KEY (MySQL) and ON CONFLICT (PostgreSQL)\n\n---\n\n## Installation\n\n```bash\ncomposer require jardissupport/dbquery\n```\n\n## Quick Start\n\n```php\nuse JardisSupport\\DbQuery\\DbQuery;\n\n$query = (new DbQuery())\n    -\u003eselect('id, name, email')\n    -\u003efrom('users')\n    -\u003ewhere('status')-\u003eequals('active')\n    -\u003eand('created_at')-\u003egreaterEquals('2024-01-01')\n    -\u003eorderBy('name')\n    -\u003elimit(50);\n\n// Generate prepared SQL for MySQL\n$prepared = $query-\u003esql('mysql', prepared: true);\n// $prepared-\u003esql()      → \"SELECT id, name, email FROM users WHERE status = ? AND created_at \u003e= ? ORDER BY name ASC LIMIT 50\"\n// $prepared-\u003ebindings() → ['active', '2024-01-01']\n```\n\n## Advanced Usage\n\n```php\nuse JardisSupport\\DbQuery\\DbQuery;\nuse JardisSupport\\DbQuery\\DbInsert;\n\n// CTE with recursive traversal\n$cte = (new DbQuery())\n    -\u003eselect('id, parent_id, name, 0 AS depth')\n    -\u003efrom('categories')\n    -\u003ewhere('parent_id')-\u003eisNull()\n    -\u003eunion(\n        (new DbQuery())\n            -\u003eselect('c.id, c.parent_id, c.name, r.depth + 1')\n            -\u003efrom('categories', 'c')\n            -\u003einnerJoin('category_tree', 'c.parent_id = r.id', 'r')\n    );\n\n$query = (new DbQuery())\n    -\u003ewithRecursive('category_tree', $cte)\n    -\u003eselect('id, name, depth')\n    -\u003efrom('category_tree')\n    -\u003eorderBy('depth')\n    -\u003eorderBy('name');\n\n// Window function for ranking\n$ranked = (new DbQuery())\n    -\u003eselect('id, customer_id, total')\n    -\u003eselectWindow('ROW_NUMBER', 'row_num')\n        -\u003eover()\n        -\u003epartitionBy('customer_id')\n        -\u003eorderBy('total', 'DESC')\n        -\u003eend()\n    -\u003efrom('orders');\n\n// JSON column condition (PostgreSQL)\n$query = (new DbQuery())\n    -\u003eselect('id, payload')\n    -\u003efrom('events')\n    -\u003ewhereJson('payload')-\u003epath('$.type')-\u003eequals('order.created')\n    -\u003eandJson('payload')-\u003epath('$.amount')-\u003egreaterEquals(100);\n\n// INSERT with conflict resolution\n$insert = (new DbInsert())\n    -\u003einto('products')\n    -\u003efields('sku', 'name', 'price')\n    -\u003evalues('ABC-001', 'Widget', 9.99)\n    -\u003eonDuplicateKey(['name', 'price']);\n\n$sql = $insert-\u003esql('mysql', prepared: true);\n```\n\n## Documentation\n\nFull documentation, guides, and API reference:\n\n**[docs.jardis.io/en/support/dbquery](https://docs.jardis.io/en/support/dbquery)**\n\n## License\n\nThis package is licensed under the [MIT License](LICENSE.md).\n\n---\n\n**[Jardis](https://jardis.io)** · [Documentation](https://docs.jardis.io) · [Headgent](https://headgent.com)\n\n\u003c!-- BEGIN jardis/dev-skills README block — do not edit by hand --\u003e\n## AI-Assisted Development\n\nThis package ships with a skill for Claude Code, Cursor, Continue, and Aider. Install it in your consuming project:\n\n```bash\ncomposer require --dev jardis/dev-skills\n```\n\nMore details: \u003chttps://docs.jardis.io/en/skills\u003e\n\u003c!-- END jardis/dev-skills README block --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjardissupport%2Fdbquery","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjardissupport%2Fdbquery","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjardissupport%2Fdbquery/lists"}