{"id":26213215,"url":"https://github.com/kumbiaphp/activerecord","last_synced_at":"2025-06-15T22:33:52.242Z","repository":{"id":14854128,"uuid":"17577316","full_name":"KumbiaPHP/ActiveRecord","owner":"KumbiaPHP","description":"New Active Record for KumbiaPHP","archived":false,"fork":false,"pushed_at":"2024-10-25T11:28:45.000Z","size":417,"stargazers_count":24,"open_issues_count":6,"forks_count":11,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-10-29T18:47:51.304Z","etag":null,"topics":["activerecord","hacktoberfest","kumbiaphp","orm","php"],"latest_commit_sha":null,"homepage":"https://kumbiaphp.com","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/KumbiaPHP.png","metadata":{"files":{"readme":"README.en.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},"funding":{"github":null,"patreon":null,"open_collective":"kumbiaphp","ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2014-03-10T00:29:15.000Z","updated_at":"2024-10-25T11:28:50.000Z","dependencies_parsed_at":"2024-11-06T12:34:22.706Z","dependency_job_id":"cd789184-4efb-4faa-8333-9c3d8052fce1","html_url":"https://github.com/KumbiaPHP/ActiveRecord","commit_stats":{"total_commits":483,"total_committers":10,"mean_commits":48.3,"dds":0.3022774327122153,"last_synced_commit":"7ef3e0b301d3b9ec2a53e356665ded8542449ef6"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KumbiaPHP%2FActiveRecord","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KumbiaPHP%2FActiveRecord/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KumbiaPHP%2FActiveRecord/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/KumbiaPHP%2FActiveRecord/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/KumbiaPHP","download_url":"https://codeload.github.com/KumbiaPHP/ActiveRecord/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248008630,"owners_count":21032556,"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","hacktoberfest","kumbiaphp","orm","php"],"created_at":"2025-03-12T09:18:02.855Z","updated_at":"2025-04-09T09:08:30.819Z","avatar_url":"https://github.com/KumbiaPHP.png","language":"PHP","funding_links":["https://opencollective.com/kumbiaphp"],"categories":[],"sub_categories":[],"readme":"![KumbiaPHP](http://proto.kumbiaphp.com/img/kumbiaphp.png)\n\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/KumbiaPHP/ActiveRecord/badges/quality-score.png?s=f7230602070a9e9605d46544197bcdac46166612)](https://scrutinizer-ci.com/g/KumbiaPHP/ActiveRecord/)\n[![Code Coverage](https://scrutinizer-ci.com/g/KumbiaPHP/ActiveRecord/badges/coverage.png?s=58997633701e84050c0ebd5334f3eb1bb8b7ad42)](https://scrutinizer-ci.com/g/KumbiaPHP/ActiveRecord/)\n[![Build Status](https://travis-ci.org/KumbiaPHP/ActiveRecord.png?branch=master)](https://travis-ci.org/KumbiaPHP/ActiveRecord)\n[![Code Climate](https://codeclimate.com/github/KumbiaPHP/ActiveRecord/badges/gpa.svg)](https://codeclimate.com/github/KumbiaPHP/ActiveRecord)\n\nENGLISH - [SPANISH](/README.md)\n\n# ActiveRecord\n\nNew ActiveRecord in development\n\nDon't use in production\n\n## Install with composer in KumbiaPHP\n\nRequires KumbiaPHP \u003e 0.9RC\n\n* Create file ***composer.json*** in to project root:\n\n```yml\n--project  \n    |  \n    |--vendor  \n    |--default  \n    |--core  \n    |--composer.json        This is our file  \n```\n\n* Add the next lines:\n\n```json\n{\n    \"require\": {\n        \"kumbia/activerecord\" : \"dev-master\"\n    }\n}\n```\n\n* Execute command **composer install**\n\n* Continue with steps number 2 and 3 of the next section.\n\n## Install in KumbiaPHP\n\nRequires KumbiaPHP \u003e 0.9RC\n\n1. Copy folder ***lib/Kumbia*** in vendor. (vendor/Kumbia/ActiveRecord/..)\n\n2. Copy [config_databases.php](/config_databases.php) in ***app/config/databases.php*** and set configuration\n\n3. Add in ***app/libs/*** : [lite_record.php](#literecord) and/or [act_record.php](#actrecord)\n\n\n### LiteRecord\n\nFor those who prefer SQL and the advantages of an ORM it includes a mini ActiveRecord\n\n```php\n\u003c?php\n//app/libs/lite_record.php\n\n/**\n * LiteRecord \n * For those who prefer SQL and the advantages of an ORM\n *\n * Parent class to add your methods\n *\n * @category Kumbia\n * @package ActiveRecord\n * @subpackage LiteRecord\n */\n\nuse Kumbia\\ActiveRecord\\LiteRecord as ORM;\n\nclass LiteRecord extends ORM\n{\n\n}\n```\n\n### ActRecord\n\nFull ActiveRecord\n\n```php\n\u003c?php\n//app/libs/act_record.php\n\n/**\n * ActiveRecord\n *\n * Parent class to add your methods\n *\n * @category Kumbia\n * @package ActiveRecord\n * @subpackage ActiveRecord\n */\n\nuse Kumbia\\ActiveRecord\\ActiveRecord;\n\nclass ActRecord extends ActiveRecord\n{\n\n}\n```\n\n# Example\n\n## Model\n\n```php\n\u003c?php\n//app/models/people.php\n\nclass People extends ActRecord //or LiteRecord depending on your choice\n{\n\n}\n```\n\n## Controller\n\n```php\n\u003c?php\n//app/controller/people_controller.php\n\n//Load::models('people'); This is not necessary in v1\n\nclass PeopleController extends AppController {\n\n    public function index() {\n        $this-\u003edata = People::all();\n    }\n    \n    public function find($id) {\n        $this-\u003edata = People::get($id);\n    }\n}\n```\n\n### Using LiteRecord methods\n\n#### Filtering data\n\n```php\n    //get all as array of records\n    $rows = People::all();\n    echo $row[0]-\u003ename;\n\n    //get by primary key as record\n    $row = People::get($peopleId);\n    echo $row-\u003ename;\n\n    //filter as array of records\n    $rows = People::filter(\"WHERE name LIKE ?\", [$peopleName]);\n    echo $rows[0]-\u003ename;\n\n    //filter by sql as record\n    $row = People::first(\"SELECT * FROM people WHERE name = :name\", [\":name\" =\u003e $peopleName]);\n    echo $row-\u003ename;\n\n    //filter by sql as array of records\n    $rows = People::all(\"SELECT * FROM people WHERE hire_date \u003e= ?\", [$hireDate]);\n    echo $rows[0]-\u003ename;\n```\n\n#### DML / Insert, update, delete\n```php\n    //adding a new record\n    $peopleObj = new People();\n    $peopleObj-\u003ecreate([\n        'name' =\u003e 'Edgard Baptista',\n        'job_title' =\u003e 'Accountant',\n        'hire_date' =\u003e date('Y-m-d'),\n        'active' =\u003e 1\n    ]); //returns True or False on success or fail\n\n    //adding a new record alternative\n    //please prefer this method by simplicity. \n    //save executes create method when primary key is missing \n    //and update ones when it exists\n    $peopleObj = new People();\n    $peopleObj-\u003esave([\n        'name' =\u003e 'Edgard Baptista',\n        'job_title' =\u003e 'Accountant',\n        'hire_date' =\u003e date('Y-m-d'),\n        'active' =\u003e 1\n    ]); //returns True or False on success or fail\n\n    //adding a new record alternative //shorthand method\n    //passing the data when instantiate the class\n    $peopleObj = new People([\n        'name' =\u003e 'Edgard Baptista',\n        'job_title' =\u003e 'Accountant',\n        'hire_date' =\u003e date('Y-m-d'),\n        'active' =\u003e 1\n    ]);\n    $peopleObj-\u003esave(); //returns True or False on success or fail\n\n    //updating a record\n    //first find the record to update\n    $peopleObj = People::get($peopleId);\n\n    $peopleObj-\u003eupdate([\n        'name' =\u003e 'Edgard Baptista Jr',\n        'active' =\u003e 0\n    ]); //returns True or False on success or fail\n\n    //updating a record alternative\n    //first find the record to update\n    $peopleObj = People::get($peopleId);\n\n    $peopleObj-\u003esave([\n        'name' =\u003e 'Edgard Baptista Jr',\n        'active' =\u003e 0\n    ]); //returns True or False on success or fail\n\n\n    //deleting a record by primary key\n    People::delete($peopleId);\n    \n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkumbiaphp%2Factiverecord","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkumbiaphp%2Factiverecord","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkumbiaphp%2Factiverecord/lists"}