{"id":19529146,"url":"https://github.com/riverside/php-orm","last_synced_at":"2025-09-07T21:11:49.809Z","repository":{"id":62536063,"uuid":"307457802","full_name":"riverside/php-orm","owner":"riverside","description":":dolphin: PHP micro-ORM and query builder","archived":false,"fork":false,"pushed_at":"2024-09-14T17:08:28.000Z","size":701,"stargazers_count":11,"open_issues_count":2,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-29T11:19:41.833Z","etag":null,"topics":["db-wrapper","micro-orm","mysql","orm","pdo","pdo-mysql","pdo-sqlite","php","php-pdo","query-builder","sqlite","sqlite3"],"latest_commit_sha":null,"homepage":"https://riverside.github.io/php-orm/","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/riverside.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","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},"funding":{"github":null,"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":"https://www.paypal.me/Dimitar81"}},"created_at":"2020-10-26T17:48:20.000Z","updated_at":"2025-04-26T07:00:17.000Z","dependencies_parsed_at":"2024-03-10T08:31:55.439Z","dependency_job_id":"5e920c27-1173-479d-b1a7-cd4a5fda7822","html_url":"https://github.com/riverside/php-orm","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/riverside/php-orm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riverside%2Fphp-orm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riverside%2Fphp-orm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riverside%2Fphp-orm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riverside%2Fphp-orm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/riverside","download_url":"https://codeload.github.com/riverside/php-orm/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riverside%2Fphp-orm/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":274095619,"owners_count":25221477,"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-09-07T02:00:09.463Z","response_time":67,"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":["db-wrapper","micro-orm","mysql","orm","pdo","pdo-mysql","pdo-sqlite","php","php-pdo","query-builder","sqlite","sqlite3"],"created_at":"2024-11-11T01:22:14.620Z","updated_at":"2025-09-07T21:11:49.783Z","avatar_url":"https://github.com/riverside.png","language":"PHP","readme":"# php-orm\nPHP micro-ORM and query builder.\n\n| Build | GitHub pages | Stable | License |\n| ----- | ------------ | ------ | ------- |\n| [![CI][x1]][y1] | [![pages-build-deployment][x4]][y4] | [![Latest Stable Version][x2]][y2] | [![License][x3]][y3] |\n\n### Requirements\n- PHP \u003e= 7.1\n- PHP extensions:\n  - PDO (`ext-pdo`)\n\n### Installation\nIf Composer is not installed on your system yet, you may go ahead and install it using this command line:\n```\n$ curl -sS https://getcomposer.org/installer | php\n```\nNext, add the following require entry to the \u003ccode\u003ecomposer.json\u003c/code\u003e file in the root of your project.\n```json\n{\n    \"require\" : {\n        \"riverside/php-orm\" : \"^2.0\"\n    }\n}\n```\nFinally, use Composer to install php-orm and its dependencies:\n```\n$ php composer.phar install \n```\n\n### Configuration\nInclude autoload in your project: \n```php\nrequire __DIR__ . '/vendor/autoload.php';\n```\n\nConfigure database credentials by setting up the following environment variables: \n`USERNAME`, `PASSWORD`, `DATABASE`, `HOST`, `PORT`, `DRIVER`, `CHARSET`, `COLLATION`. They must be \nprefixed with `$connection` property value, part of your model, in capital letters and underscore. The default value of `$connection` \nproperty is 'default'. For example:\n```php\n\u003c?php\nputenv(\"DEFAULT_USERNAME=your_username\");\nputenv(\"DEFAULT_PASSWORD=your_password\");\nputenv(\"DEFAULT_DATABASE=your_database\");\nputenv(\"DEFAULT_HOST=localhost\");\nputenv(\"DEFAULT_PORT=3306\");\nputenv(\"DEFAULT_DRIVER=mysql\");\nputenv(\"DEFAULT_CHARSET=utf8mb4\");\nputenv(\"DEFAULT_COLLATION=utf8mb4_general_ci\");\n```\n### Drivers\nThe following drivers are supported: `mysql`, `oci`, `firebird`, `pgsql`, `sqlite`, `sybase`, `mssql`, `dblib`, `cubrid`, `4D`.\n\n### Database\nTable: **users**\n\n| Name | Type | Collation | Attributes | Null| Extra |\n| --- | --- | --- | --- | --- | --- |\n| id | int(10) | | UNSIGNED | No | AUTO_INCREMENT |\n| name | varchar(255) | utf8mb4_general_ci | | Yes | |\n| email | varchar(255) | utf8mb4_general_ci | | Yes | |\n\n### Models\nDefine your own models:\n```php\n\u003c?php\nuse Riverside\\Orm\\DB;\n\nclass User extends DB\n{\n    protected $table = 'users';\n    \n    protected $attributes = ['id', 'name', 'email'];\n    \n    // protected $connection = 'backup';\n    \n    public static function factory()\n    {\n        return new self();\n    }\n}\n```\n\n### Query Builder\n- with model:\n create an instance of a model using the `factory` method. Then chain multiple methods.\n The following is example of simple CRUD:\n```php\n$id = User::factory()-\u003einsert(['name' =\u003e 'Chris', 'email' =\u003e 'chris@aol.com']);\n$user = User::factory()-\u003ewhere('id', $id)-\u003eget();\n$affected_rows = User::factory()-\u003ewhere('id', $id)-\u003eupdate(['name' =\u003e 'Chris Johnson']);\n$affected_rows = User::factory()-\u003ewhere('id', $id)-\u003edelete();\n```\n\n- without model: create a new instance of `Riverside\\Orm\\DB` class\n```php\n$db = new \\Riverside\\Orm\\DB();\n$db-\u003etable('users')-\u003eget();\n```\n\n### API\n- [DB][1]\n- [Expression][2]\n- [Configuration][3]\n- [Connection][4]\n\n[1]: https://riverside.github.io/php-orm/api.html#db\n[2]: https://riverside.github.io/php-orm/api.html#expr\n[3]: https://riverside.github.io/php-orm/api.html#cfg\n[4]: https://riverside.github.io/php-orm/api.html#con\n[x1]: https://github.com/riverside/php-orm/actions/workflows/test.yml/badge.svg\n[y1]: https://github.com/riverside/php-orm/actions/workflows/test.yml\n[x2]: https://poser.pugx.org/riverside/php-orm/v/stable\n[y2]: https://packagist.org/packages/riverside/php-orm\n[x3]: https://poser.pugx.org/riverside/php-orm/license\n[y3]: https://packagist.org/packages/riverside/php-orm\n[x4]: https://github.com/riverside/php-orm/actions/workflows/pages/pages-build-deployment/badge.svg\n[y4]: https://github.com/riverside/php-orm/actions/workflows/pages/pages-build-deployment","funding_links":["https://www.paypal.me/Dimitar81"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Friverside%2Fphp-orm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Friverside%2Fphp-orm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Friverside%2Fphp-orm/lists"}