{"id":19593934,"url":"https://github.com/edsonbonfim/php-orm","last_synced_at":"2025-02-26T14:18:16.333Z","repository":{"id":56951132,"uuid":"124445597","full_name":"edsonbonfim/PHP-ORM","owner":"edsonbonfim","description":"Implementação do padrão de projeto active record em PHP","archived":false,"fork":false,"pushed_at":"2019-09-15T20:17:55.000Z","size":100,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-09T07:11:07.804Z","etag":null,"topics":["activerecord","database","model","orm","pdo","php","sql"],"latest_commit_sha":null,"homepage":"","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/edsonbonfim.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-08T20:40:13.000Z","updated_at":"2021-05-19T22:48:39.000Z","dependencies_parsed_at":"2022-08-21T07:40:29.259Z","dependency_job_id":null,"html_url":"https://github.com/edsonbonfim/PHP-ORM","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edsonbonfim%2FPHP-ORM","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edsonbonfim%2FPHP-ORM/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edsonbonfim%2FPHP-ORM/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/edsonbonfim%2FPHP-ORM/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/edsonbonfim","download_url":"https://codeload.github.com/edsonbonfim/PHP-ORM/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240867432,"owners_count":19870405,"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","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":["activerecord","database","model","orm","pdo","php","sql"],"created_at":"2024-11-11T08:41:47.285Z","updated_at":"2025-02-26T14:18:16.291Z","avatar_url":"https://github.com/edsonbonfim.png","language":"PHP","readme":"activerecord.php\n================\n\n[![Latest Version on Packagist][ico-version]][link-packagist]\n[![Software License][ico-license]](LICENSE.md)\n[![Build Status][ico-travis]][link-travis]\n[![Coverage Status][ico-scrutinizer]][link-scrutinizer]\n[![Quality Score][ico-code-quality]][link-code-quality]\n[![Total Downloads][ico-downloads]][link-downloads]\n\nImplementação do padrão de projeto active record em PHP\n\nTable of Contents\n-----------------\n\n* [Prerequisites](#prerequisites)\n* [Supported Databases](#supported-databases)\n* [Installation](#installation)\n* [Basic CRUD](#basic-crud)\n    * [Retrieve](#retrieve)\n    * [Create](#create)\n    * [Update](#update)\n    * [Delete](#delete)\n* [Contributing](#contributing)\n* [Security](#security)\n* [Credits](#credits)\n* [License](#license)\n\nPrerequisites\n-------------\n\n* PHP 7.1+\n* PDO driver for your respective database\n\nSupported Databases\n-------------------\n\n* MySQL\n* SQLite\n* PostgreSQL\n* Oracle\n\nInstallation\n------------\n\nRequire via [composer](https://getcomposer.org/download/)\n\n``` sh\n$ composer require edsononildo/orm\n```\n\nCreate an **index.php** file and require the autoload.php of composer\n\n```php\n\u003c?php\n\ninclude 'vendor/autoload.php';\n```\n\nAfter that, let's to do all necessary configuration\n\n```php\nuse Bonfim\\ActiveRecord\\ActiveRecord;\n\nActiveRecord::config('mysql:host=localhost;dbname=testdb', 'username', 'password');\n```\n\nBasic CRUD\n----------\n\n### Retrieve\n\nThese are your basic methods to find and retrieve records from your database:\n\n```php\n// Retrieve all records\n$posts = Post::all();\n\n// Retrieve records with specific keys\n$posts = Post::select(['title']);\n\n// Find records with a condition\n$posts = Post::find('WHERE id = ?', [1]);\n```\n\n### Create\n\nHere we create a new post by instantiating a new object and then invoking the save() method:\n\n```php\n$post = new Post();\n$post-\u003etitle = 'My first blog post!!';\n$post-\u003eauthor_name = 'Edson Onildo';\n$post-\u003esave();\n```\n\n```sql\nINSERT INTO `posts` (`title`, `author_name`) VALUES (\"My first blog post!!\", \"Edson Onildo\");\n```\n\n### Update\n\nTo update you would just need to find a record first and then change one of its attributes.\n\n```php\n$post = Post::find('WHERE `id` = ?', [1])[0];\necho $post-\u003etitle; // 'My first blog post!!'\n$post-\u003etitle = 'Some title';\n$post-\u003esave();\n```\n\n```sql\nUPDATE `posts` SET title='Some title' WHERE id=1;\n```\n\n### Delete\n\nDeleting a record will not destroy the object. This means that it will call sql to delete the record in your database but you can still use the object if you need to.\n\n```php\n$post = Post::find('WHERE `id` = ?');\n$post-\u003edelete();\n```\n\n```sql\nDELETE FROM `posts` WHERE id=1;\n```\n\nChange log\n----------\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.\n\nTesting\n-------\n\n``` bash\n$ composer test\n```\n\nContributing\n------------\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) and [CODE_OF_CONDUCT](CODE_OF_CONDUCT.md) for details.\n\nSecurity\n--------\n\nIf you discover any security related issues, please email inbox.edsononildo@gmail.com instead of using the issue tracker.\n\nCredits\n-------\n\n- [Edson Onildo][link-author]\n- [All Contributors][link-contributors]\n\nLicense\n-------\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n[ico-version]: https://img.shields.io/packagist/v/edsononildo/orm.svg?style=flat-square\n[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\n[ico-travis]: https://img.shields.io/travis/EdsonOnildoJR/activerecord.php/master.svg?style=flat-square\n[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/EdsonOnildoJR/activerecord.php.svg?style=flat-square\n[ico-code-quality]: https://img.shields.io/scrutinizer/g/EdsonOnildoJR/activerecord.php.svg?style=flat-square\n[ico-downloads]: https://img.shields.io/packagist/dt/edsononildo/orm.svg?style=flat-square\n\n[link-packagist]: https://packagist.org/packages/edsononildo/orm\n[link-travis]: https://travis-ci.org/EdsonOnildoJR/activerecord.php\n[link-scrutinizer]: https://scrutinizer-ci.com/g/EdsonOnildoJR/activerecord.php/code-structure\n[link-code-quality]: https://scrutinizer-ci.com/g/EdsonOnildoJR/activerecord.php\n[link-downloads]: https://packagist.org/packages/edsononildo/orm\n[link-author]: https://github.com/EdsonOnildoJR\n[link-contributors]: ../../contributors\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedsonbonfim%2Fphp-orm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fedsonbonfim%2Fphp-orm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fedsonbonfim%2Fphp-orm/lists"}