{"id":31923403,"url":"https://github.com/rougin/ezekiel","last_synced_at":"2025-10-13T23:50:20.633Z","repository":{"id":57047493,"uuid":"152700449","full_name":"rougin/ezekiel","owner":"rougin","description":"An expressive SQL query builder in PHP.","archived":false,"fork":false,"pushed_at":"2025-09-22T03:37:10.000Z","size":142,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-09-22T04:30:32.492Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://roug.in/ezekiel/","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/rougin.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"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":"2018-10-12T05:52:19.000Z","updated_at":"2025-09-22T03:37:14.000Z","dependencies_parsed_at":"2025-09-22T04:30:35.057Z","dependency_job_id":"8931d37f-5fce-46fd-a334-1d43e15789f1","html_url":"https://github.com/rougin/ezekiel","commit_stats":null,"previous_names":["rougin/ezekiel"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/rougin/ezekiel","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rougin%2Fezekiel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rougin%2Fezekiel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rougin%2Fezekiel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rougin%2Fezekiel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rougin","download_url":"https://codeload.github.com/rougin/ezekiel/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rougin%2Fezekiel/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279017229,"owners_count":26086016,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"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":[],"created_at":"2025-10-13T23:50:18.878Z","updated_at":"2025-10-13T23:50:20.621Z","avatar_url":"https://github.com/rougin.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ezekiel\n\n[![Latest Version on Packagist][ico-version]][link-packagist]\n[![Software License][ico-license]][link-license]\n[![Build Status][ico-build]][link-build]\n[![Coverage Status][ico-coverage]][link-coverage]\n[![Total Downloads][ico-downloads]][link-downloads]\n\nAn expressive SQL query builder in PHP. This package is previously known as [Windstorm](https://github.com/rougin/ezekiel/tree/c95c77506087db19033997d1e752ce01c9294056).\n\n## Installation\n\nInstall `Ezekiel` through [Composer](https://getcomposer.org/):\n\n``` bash\n$ composer require rougin/ezekiel\n```\n\n## Basic usage\n\nUse the `Query` class to create SQL queries:\n\n``` php\nuse Rougin\\Ezekiel\\Query;\n\n$query = (new Query)\n    -\u003eselect(array('u.id', 'u.name', 'p.name as position'))\n    -\u003efrom('users u')\n    -\u003eleftJoin('positions p')-\u003eon('p.id', 'u.position_id')\n    -\u003ewhere('u.name')-\u003elike('%winds%')\n    -\u003ehaving('u.id')-\u003egreaterThan(0)\n    -\u003eorderBy('u.created_at')-\u003edesc();\n\n// SELECT u.id, u.name, p.name as position\n// FROM users u\n// LEFT JOIN positions p ON p.id = u.position_id\n// WHERE u.name LIKE ? HAVING u.id \u003e ?\n// ORDER BY u.created_at DESC\n$sql = $query-\u003etoSql();\n\n// array('name' =\u003e '%winds%', 'id' =\u003e 0)\n$binds = $query-\u003egetBinds();\n```\n\nAfter creating the query, use the `Result` class to return its contents:\n\n``` php\nuse Rougin\\Ezekiel\\Query;\nuse Rougin\\Ezekiel\\Result;\n\n$query = (new Query)\n    -\u003eselect(array('u.id', 'u.name'))\n    -\u003efrom('users', 'u')\n    -\u003ewhere('name')-\u003elike('%winds%')\n    -\u003eorderBy('created_at')-\u003edesc();\n\n$pdo = /** returns a PDO instance */;\n\n$result = new Result($pdo);\n\n$items = $result-\u003eitems($query);\n\necho json_encode($items);\n```\n\n``` json\n[\n  {\n    \"id\": 2,\n    \"name\": \"Windsor\",\n    \"created_at\": \"2018-10-15 23:09:47\",\n    \"updated_at\": null\n  },\n  {\n    \"id\": 1,\n    \"name\": \"Windstorm\",\n    \"created_at\": \"2018-10-15 23:06:28\",\n    \"updated_at\": null\n  },\n  {\n    \"id\": 3,\n    \"name\": \"Windsy\",\n    \"created_at\": \"2018-10-15 23:14:45\",\n    \"updated_at\": null\n  }\n]\n```\n\nFor returning only one item from the result, use the `first` method instead:\n\n``` php\n// ...\n\nuse Rougin\\Ezekiel\\Result;\n\n// ...\n\n$result = new Result($pdo);\n\n$items = $result-\u003efirst($query);\n\necho json_encode($items);\n```\n\n``` json\n{\n  \"id\": 2,\n  \"name\": \"Windsor\",\n  \"created_at\": \"2018-10-15 23:09:47\",\n  \"updated_at\": null\n}\n```\n\n## Using entities\n\nFor mapping query results into an entity object, the entity can be extended to the `Entity` class:\n\n```php\n// src/Entities/User.php\n\nnamespace Test\\Entities;\n\nuse Rougin\\Ezekiel\\Entity;\n\nclass User extends Entity\n{\n    protected $id;\n\n    protected $name;\n\n    public function getId()\n    {\n        return $this-\u003eid;\n    }\n\n    public function getName()\n    {\n        return $this-\u003ename;\n    }\n\n    public function setName($name)\n    {\n        $this-\u003ename = $name;\n\n        return $this;\n    }\n}\n```\n\nIf an `Entity` is passed to the `Result` class, the results will be automatically to new instances of that `Entity`:\n\n```php\nuse Rougin\\Ezekiel\\Query;\nuse Rougin\\Ezekiel\\Result;\nuse Test\\Entities\\User;\n\n$user = (new User)\n    -\u003eselect('id, name')-\u003efrom('users')\n    -\u003ewhere('name')-\u003eequals('Windsor');\n\n$pdo = /** returns a PDO instance */ ;\n\n$result = new Result($pdo);\n\n/** @var \\Rougin\\Ezekiel\\Fixture\\Entities\\User[] */\n$users = $result-\u003eitems($user);\n\nforeach ($users as $user)\n{\n    echo 'Hello ' . $user-\u003egetName() . '!\u003cbr\u003e';\n}\n```\n\n## Available methods\n\nAll available SQL statements should be supported by `Ezekiel`. These includes `DELETE FROM`, `INSERT INTO`, `SELECT`, and `UPDATE`:\n\n### DELETE\n\n``` php\nuse Rougin\\Ezekiel\\Query;\n\n$query = (new Query)\n    -\u003edeleteFrom('users')\n    -\u003ewhere('id')-\u003eequals(12);\n\n// DELETE FROM users WHERE id = ?\n$sql = $query-\u003etoSql();\n\n// array('id' =\u003e 12)\n$binds = $query-\u003egetBinds();\n```\n\n### INSERT\n\n``` php\nuse Rougin\\Ezekiel\\Query;\n\n$query = (new Query)\n    -\u003einsertInto('users')\n    -\u003evalues(array('name' =\u003e 'Ezekiel', 'age' =\u003e 20));\n\n// INSERT INTO users (name, age) VALUES (?, ?)\n$sql = $query-\u003etoSql();\n\n// array('name' =\u003e 'Ezekiel', 'age' =\u003e 20)\n$binds = $query-\u003egetBinds();\n```\n\n### SELECT\n\n``` php\n$query = (new Query)\n    -\u003eselect(array('u.id', 'u.name'))\n    -\u003efrom('users u')\n    -\u003ewhere('u.name')-\u003elike('%winds%')\n    -\u003eorderBy('u.created_at')-\u003edesc();\n\n// SELECT u.id, u.name FROM users u\n// WHERE u.name LIKE ?\n// ORDER BY u.created_at DESC\n$sql = $query-\u003etoSql();\n\n// array('name' =\u003e '%winds%')\n$binds = $query-\u003egetBinds();\n```\n\n### UPDATE\n\n``` php\nuse Rougin\\Ezekiel\\Query;\n\n$query = (new Query)\n    -\u003eupdate('users')\n    -\u003eset('name', 'Ezekiel')\n    -\u003ewhere('id')-\u003eequals(12);\n\n// UPDATE users SET name = ? WHERE id = ?\n$sql = $query-\u003etoSql();\n\n// array('name' =\u003e 'Ezekiel', 'id' =\u003e 12)\n$binds = $query-\u003egetBinds();\n```\n\n## Renaming from `Windstorm`\n\nAs being renamed from `Windstorm`, this will introduce [backward compatibility](https://en.wikipedia.org/wiki/Backward_compatibility) (BC) breaks through out the source code. This was done to increase extensibility, simplicity and maintainbility and was discussed in one of [my blog post](https://roug.in/hello-world-again/) which aims to solve overengineering of my own open source packages:\n\n\u003e I also want to extend this plan to my personal packages as well like [Staticka](https://github.com/staticka/staticka) and [Transcribe](https://github.com/rougin/transcribe). With this, I will introduce backward compatibility breaks to them initially as it is hard to migrate their codebase due to minimal to no documentation being provided in its basic usage and its internals. As I checked their code, I realized that they are also over engineered, which is a mistake that I needed to atone for when updating my packages in the future.\n\nSince the previous name was never released with a version, no `UPGRADING.md` was created. As such, please see [commit c95c775](https://github.com/rougin/ezekiel/tree/c95c77506087db19033997d1e752ce01c9294056) of this repository for the files that were removed or updated in this last commit.\n\n## Changelog\n\nPlease see [CHANGELOG][link-changelog] for more information what has changed recently.\n\n## Development\n\nIncludes tools for code quality, coding style, and unit tests.\n\n### Code quality\n\nAnalyze code quality using [phpstan](https://phpstan.org/):\n\n``` bash\n$ phpstan\n```\n\n### Coding style\n\nEnforce coding style using [php-cs-fixer](https://cs.symfony.com/):\n\n``` bash\n$ php-cs-fixer fix --config=phpstyle.php\n```\n\n### Unit tests\n\nExecute unit tests using [phpunit](https://phpunit.de/index.html):\n\n``` bash\n$ vendor/bin/phpunit\n```\n\n## Credits\n\n- [All contributors][link-contributors]\n\n## License\n\nThe MIT License (MIT). Please see [LICENSE][link-license] for more information.\n\n[ico-build]: https://img.shields.io/github/actions/workflow/status/rougin/ezekiel/build.yml?style=flat-square\n[ico-coverage]: https://img.shields.io/codecov/c/github/rougin/ezekiel?style=flat-square\n[ico-downloads]: https://img.shields.io/packagist/dt/rougin/ezekiel.svg?style=flat-square\n[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\n[ico-version]: https://img.shields.io/packagist/v/rougin/ezekiel.svg?style=flat-square\n\n[link-build]: https://github.com/rougin/ezekiel/actions\n[link-changelog]: https://github.com/rougin/ezekiel/blob/master/CHANGELOG.md\n[link-contributors]: https://github.com/rougin/ezekiel/contributors\n[link-coverage]: https://app.codecov.io/gh/rougin/ezekiel\n[link-downloads]: https://packagist.org/packages/rougin/ezekiel\n[link-license]: https://github.com/rougin/ezekiel/blob/master/LICENSE.md\n[link-packagist]: https://packagist.org/packages/rougin/ezekiel\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frougin%2Fezekiel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frougin%2Fezekiel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frougin%2Fezekiel/lists"}