{"id":20765378,"url":"https://github.com/mcred/phpred","last_synced_at":"2025-12-25T05:11:19.055Z","repository":{"id":57016682,"uuid":"92975655","full_name":"mcred/phpred","owner":"mcred","description":"Relationships, Entities and Datasources for PHP","archived":false,"fork":false,"pushed_at":"2017-08-31T14:00:57.000Z","size":41,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-18T06:11:41.634Z","etag":null,"topics":["codeclimate","orm","php7","phpunit-6","test-driven-development","travis-ci"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mcred.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-05-31T18:20:01.000Z","updated_at":"2022-02-12T08:29:56.000Z","dependencies_parsed_at":"2022-08-22T09:40:38.508Z","dependency_job_id":null,"html_url":"https://github.com/mcred/phpred","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcred%2Fphpred","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcred%2Fphpred/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcred%2Fphpred/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcred%2Fphpred/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mcred","download_url":"https://codeload.github.com/mcred/phpred/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243093068,"owners_count":20235291,"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":["codeclimate","orm","php7","phpunit-6","test-driven-development","travis-ci"],"created_at":"2024-11-17T11:16:35.569Z","updated_at":"2025-12-25T05:11:14.010Z","avatar_url":"https://github.com/mcred.png","language":"PHP","readme":"# PHPRed\n[![Build Status](https://travis-ci.org/mcred/phpred.svg?branch=master)](https://travis-ci.org/mcred/phpred)\n[![Code Climate](https://codeclimate.com/github/mcred/phpred/badges/gpa.svg)](https://codeclimate.com/github/mcred/phpred)\n[![Test Coverage](https://codeclimate.com/github/mcred/phpred/badges/coverage.svg)](https://codeclimate.com/github/mcred/phpred/coverage)\n[![Issue Count](https://codeclimate.com/github/mcred/phpred/badges/issue_count.svg)](https://codeclimate.com/github/mcred/phpred)\n\n### Description\n\u003cp\u003ePHPRed is an opinionated light weight ORM. While there are many available ORMs for PHP, many contain features that I have never used. PHPRed contains very basic methods and usage.\u003c/p\u003e\n\n### Requirements\n* PHP 7.1+\n* Composer\n* Mysqli\n\n### Installation\n\n```\ncomposer require mcred/phpred\n```\n\n### Setup\n\u003cp\u003eIn addition to the example below, there are examples available in the `tests/mocks` folder. Setting up a model is very easy: create a model class that extends the `PHPRed/Models/Model` class then define the properties of that model in the constructor. Such as: \u003c/p\u003e\n\n```php\n\u003c?php\nclass MyClass extends \\PHPRed\\Models\\Model\n{\n    public function __construct(\\MysqliDb $mysql)\n    {\n        $this-\u003emodel = 'MyClass';\n        $this-\u003etable = 'my_class';\n        $this-\u003eprimaryKey = 'id';\n        $this-\u003eforeignKey = 'my_class_id';\n        $this-\u003efields = ['id', 'name'];\n        $this-\u003erequiredFields = ['name'];\n        $this-\u003euniqueFields = ['name'];\n        $this-\u003ehasMany = ['MyClassProperties'];\n        $this-\u003ehasAndBelongsToMany = ['Users'];\n\n        parent::__construct($mysql);\n    }\n}\n\n```\n\n### Constructor Properties\n* model: string\n* table: string\n* primaryKey: string\n* foreignKey: string\n* fields: array\n* requiredFields: array\n* uniqueFields: array\n* hasMany: array\n* belongsTo: array\n* hasAndBelongsToMany: array\n\n### Methods\n* getAll() : array\n* getById(int $modelId) : array\n* getBySearch(array ['key' =\u003e 'value']) : array\n* insert(array $data) : array\n* updateById(int $modelId, array $data) : array\n* deleteById(int $modelId): void\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcred%2Fphpred","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmcred%2Fphpred","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcred%2Fphpred/lists"}