{"id":16349528,"url":"https://github.com/arojunior/php-orm-pdo","last_synced_at":"2025-09-04T06:34:48.562Z","repository":{"id":62487684,"uuid":"66774227","full_name":"arojunior/php-orm-pdo","owner":"arojunior","description":"Micro PHP ORM Library","archived":false,"fork":false,"pushed_at":"2018-09-15T17:31:48.000Z","size":43,"stargazers_count":19,"open_issues_count":4,"forks_count":5,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-17T19:11:34.710Z","etag":null,"topics":["crud","orm","php","php-orm-pdo"],"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/arojunior.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-08-28T14:59:57.000Z","updated_at":"2024-06-12T16:49:53.000Z","dependencies_parsed_at":"2022-11-02T11:00:38.612Z","dependency_job_id":null,"html_url":"https://github.com/arojunior/php-orm-pdo","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arojunior%2Fphp-orm-pdo","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arojunior%2Fphp-orm-pdo/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arojunior%2Fphp-orm-pdo/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/arojunior%2Fphp-orm-pdo/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/arojunior","download_url":"https://codeload.github.com/arojunior/php-orm-pdo/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244717173,"owners_count":20498280,"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":["crud","orm","php","php-orm-pdo"],"created_at":"2024-10-11T01:00:12.437Z","updated_at":"2025-03-21T00:30:36.628Z","avatar_url":"https://github.com/arojunior.png","language":"PHP","readme":"### Installing via composer and using as a lib\n\n```shell\ncomposer require arojunior/php-orm-pdo\n```\n\n### create a file to overwrite the database config\n\n```php\nuse SimpleORM\\core\\model\\Model;\n\nclass AppModel extends Model\n{\n    public $db_config = [\n        'db_host' =\u003e '192.168.1.1',\n        'db_name' =\u003e 'test',\n        'db_user' =\u003e 'root',\n        'db_pass' =\u003e ''\n    ];\n}\n\n```\n\n#### And then you can extend this class in your classes\n\n```php\nuse YourNamespace\\AppModel;\n\nclass Example extends AppModel\n{\n    public $table = 't_user';\n    public $pk    = 'user_id';\n\n    public function getAll()\n    {\n        return $this-\u003efindAll();\n    }\n}\n```\n\n### CRUD\n\n```php\n\nnamespace SimpleORM\\app\\model;\n\nuse SimpleORM\\core\\model\\Model;\n\nclass Users extends Model\n{\n    \t/*\n        * * Basic configuration\n        * These arguments are optionals\n        * protected $table = 'users'; //just if the class name a table name are different\n        * protected $pk = 'id'; //just if the primary key name is not id\n      */\t    \t    \n}\n\n```\n\n### Creating a new user (without check)\n\n```php\n$this-\u003eUsers-\u003ecreate([\n  'name' =\u003e 'Junior Oliveira',\n  'email' =\u003e 'arojunior@gmail.com'\n]);\n```\n\n**Let the ORM choose if it will be created or updated. The ORM will execute the find method before to decide if will create or update data**\n\n### Saving data\n\n```php\n$this-\u003eUsers-\u003esave([\n  'id' =\u003e 1,\n  'name' =\u003e 'Junior Oliveira'\n]);\n```\n\n### Retrieving the id\n\n```php\n$this-\u003eUsers-\u003elastSavedId();\n```\n\n### Updating a user with id = 1\n\n```php\n$this-\u003eUsers-\u003eupdate([\n  'id' =\u003e 1,\n  'email' =\u003e 'contato@arojunior.com'\n]);\n```\n\n### Delete\n\n```php\n$this-\u003eUsers-\u003edelete(['id' =\u003e 1]);\n```\n\n## Read\n\n```php\n$this-\u003eUsers-\u003efindAll(); // fetchAll\n\n$this-\u003eUsers-\u003efindOne(['email' =\u003e 'arojunior@gmail.com']);\n\n$this-\u003eUsers-\u003efindById($id);\n```\n\n### Checking\n\n```php\n$this-\u003eUsers-\u003eexists($id);\n```\n\nin case of true, you cat get the data with:\n\n```php\n$this-\u003eUsers-\u003efetch();\n```\n\n### Functionalities if used as Framework\n\n- CRUD functions\n- Auto load Model classes in Controllers\n- To use the automatic functions you should use the filename and structure conventions\n- Just follow the example on /controller/UsersController.php\n- All controllers in /app/controllers folder\n- All models in /app/models folder\n\n### Convetions\n\n- All controllers in /app/controller path\n- All models in /app/model path\n- All views in /app/view path\n- Filenames and classes must has the same name\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farojunior%2Fphp-orm-pdo","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Farojunior%2Fphp-orm-pdo","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Farojunior%2Fphp-orm-pdo/lists"}