{"id":22930944,"url":"https://github.com/mohammadreza-73/astro-orm","last_synced_at":"2025-08-01T17:36:43.910Z","repository":{"id":54635611,"uuid":"433058724","full_name":"Mohammadreza-73/Astro-ORM","owner":"Mohammadreza-73","description":"Simple Object Relational Mapper for manipulate data with fluent interface and TDD approach.","archived":false,"fork":false,"pushed_at":"2024-01-13T21:02:37.000Z","size":192,"stargazers_count":3,"open_issues_count":2,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-30T19:17:34.902Z","etag":null,"topics":["database","fluent-api","mysql-orm","orm","pdo-php","php-orm","sql","tdd"],"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/Mohammadreza-73.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null},"funding":{"custom":"https://daramet.com/mrahimi"}},"created_at":"2021-11-29T13:43:27.000Z","updated_at":"2024-01-13T20:33:12.000Z","dependencies_parsed_at":"2022-08-13T22:20:17.018Z","dependency_job_id":"3457fe9f-9902-44f8-9f5f-7851167c7f8b","html_url":"https://github.com/Mohammadreza-73/Astro-ORM","commit_stats":{"total_commits":43,"total_committers":2,"mean_commits":21.5,"dds":"0.023255813953488413","last_synced_commit":"410c5d4b1d4633ca0e2c5f26cf7c22fb2078b25f"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mohammadreza-73%2FAstro-ORM","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mohammadreza-73%2FAstro-ORM/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mohammadreza-73%2FAstro-ORM/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mohammadreza-73%2FAstro-ORM/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Mohammadreza-73","download_url":"https://codeload.github.com/Mohammadreza-73/Astro-ORM/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229694561,"owners_count":18108931,"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":["database","fluent-api","mysql-orm","orm","pdo-php","php-orm","sql","tdd"],"created_at":"2024-12-14T10:32:24.396Z","updated_at":"2024-12-14T10:33:39.830Z","avatar_url":"https://github.com/Mohammadreza-73.png","language":"PHP","readme":"\u003cimg src=\"https://banners.beyondco.de/Astro%20ORM.png?theme=dark\u0026packageManager=composer+require\u0026packageName=m.rahimi%2Fastro-orm\u0026pattern=bamboo\u0026style=style_1\u0026description=lightweight+PHP+ORM\u0026md=1\u0026showWatermark=1\u0026fontSize=100px\u0026images=https%3A%2F%2Fwww.php.net%2Fimages%2Flogos%2Fnew-php-logo.svg\u0026widths=350\u0026heights=350\" alt=\"astro-orm-banner\"\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://packagist.org/packages/m.rahimi/astro-orm\"\u003e\u003cimg src=\"https://img.shields.io/packagist/dt/m.rahimi/astro-orm\" alt=\"Total Downloads\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/m.rahimi/astro-orm\"\u003e\u003cimg src=\"https://img.shields.io/packagist/v/m.rahimi/astro-orm\" alt=\"Latest Stable Version\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.styleci.io/repos/433058724?branch=master\"\u003e\u003cimg src=\"https://github.styleci.io/repos/433058724/shield?branch=master\" alt=\"StyleCI\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/m.rahimi/astro-orm\"\u003e\u003cimg src=\"https://img.shields.io/packagist/l/m.rahimi/astro-orm\" alt=\"License\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://phpstan.org/\"\u003e\u003cimg src=\"https://img.shields.io/badge/PHPStan-level%206-brightgreen.svg?style=flat\" alt=\"PHPStan\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\nobject-relational mapper (ORM), lets you query and manipulate data with fluent api from a database using an object-oriented paradigm.\n\n## 📌 Requirements\n - PHP \u003e= 7.2\n - PDO Extension\n\n## ⬇️ Installation\nYou can install the package via the composer:\n```\ncomposer require m.rahimi/astro-orm\n```\n\n## 👀 How its works\n\u003cp align=\"center\"\u003e\n    \u003cimg src=\"docs/UML Diagram.jpg\" alt=\"UML\" align=\"center\"\u003e\n\u003c/p\u003e\n\n### 1. Setup your database configs\nFill the ```config/database.php``` file with your database configuration.\n\n**NOTE:** You Can use any database extensions, like: PDO, Mysqli, Sqlite,etc. Just define its array key.\n\n### 2. Implements Connection Contract\n\nIn this project i use PDO driver. so i create `Database/PDODatabaseConnection.php` file and implements contracts methods.\n\n```php\nconnect();        // Which implements database connection\ngetConnection();  // Which return database connection\n```\n\n### 3. Use Query Builder\n\nNow get database configs, create new instanse of `PDODatabaseConnection` and connect to DB.\n\n```php\n$this-\u003econfig = $this-\u003egetConfigs('database', 'astro_orm');\n\n$pdoConnection = new PDODatabaseConnection($this-\u003econfig);\n$pdoHandler = $pdoConnection-\u003econnect();\n```\n\n#### Insert\n\nInsert Data: return last insert id\n\n```php\n$data = [\n    'name'  =\u003e 'John',\n    'email' =\u003e 'john.doe@gmail.com',\n    'link'  =\u003e 'https://example.com',\n    'skill' =\u003e 'PHP'\n];\n\n$last_id = PDOQueryBuilder::table('users')-\u003ecreate($data);\n```\n\n#### update\n\nUpdate Data: return true if successful\n\n```php\n$result = PDOQueryBuilder::table('users')\n    -\u003ewhere('name', 'John')\n    -\u003ewhere('skill', 'PHP')\n    -\u003eupdate([\n        'skill' =\u003e 'Javascript',\n        'name' =\u003e 'Jeff',\n        'email' =\u003e 'jeff@gmail.com'\n    ]);\n```\n\n#### Multiple where\n\n```php\n$result = PDOQueryBuilder::table('users')\n    -\u003ewhere('name', 'John')\n    -\u003ewhere('skill', 'JS')\n    -\u003eupdate(['skill' =\u003e 'Javascript']);\n```\n\n#### Multiple orWhere\n\n```php\n$result = PDOQueryBuilder::table('users')\n    -\u003eorWhere('skill', 'PHP')\n    -\u003eorWhere('skill', 'JS')\n    -\u003eget();\n```\n\n#### Delete\n\nDelete Data: return true if successful\n\n```php\n$result = PDOQueryBuilder::table('users')\n    -\u003ewhere('name', 'John')\n    -\u003edelete();\n```\n\n#### Fetch\n\n```php\n$result = PDOQueryBuilder::table('users')\n    -\u003ewhere('name', 'John')\n    -\u003ewhere('skill', 'Javascript')\n    -\u003eget();\n```\n\n#### Fetch first row\n\n```php\n$result = PDOQueryBuilder::table('users')\n    -\u003ewhere('name', 'First Row')\n    -\u003efirst();\n```\n\n#### Fetch first row or throw exception on failure\n\n```php\n$result = PDOQueryBuilder::table('users')\n    -\u003ewhere('name', 'Jim')\n    -\u003efirstOrFail();\n```\n\n#### Find ID\n\n```php\n$result = PDOQueryBuilder::table('users')\n    -\u003efind($id);\n```\n\n#### Find ID or throw exception on failure\n\n```php\n$result = PDOQueryBuilder::table('users')\n    -\u003efindOrFail($id);\n```\n\n#### Find with value\n\n```php\n$result = PDOQueryBuilder::table('users')\n    -\u003efindBy('name', 'Jack');\n```\n\n#### Get specific rows\n\n```php\n$result = PDOQueryBuilder::table('users')\n    -\u003ewhere('name', 'Jack')\n    -\u003elimit(5)\n    -\u003eget();\n```\n\n#### Sort rows\n\n```php\n$result = PDOQueryBuilder::table('users')\n    -\u003eorderBy('skill', 'DESC')\n    -\u003eget();\n```\n\n## Testing\n\nRun the tests with:\n```php\ncomposer test\n```\n\n## Contributing\n\nContributions are welcome! To contribute, please familiarize yourself with [CONTRIBUTE.md](CONTRIBUTING.md)\n\n## Security\n\nIf you discover any security related issues, please email [mohammadreza.rahimi1373@gmail.com](mailto:mohammadreza.rahimi1373@gmail.com) instead of using the issue tracker.\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE) for more information.","funding_links":["https://daramet.com/mrahimi"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmohammadreza-73%2Fastro-orm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmohammadreza-73%2Fastro-orm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmohammadreza-73%2Fastro-orm/lists"}