{"id":19663974,"url":"https://github.com/fykosak/nette-orm","last_synced_at":"2025-07-22T03:31:33.926Z","repository":{"id":45261879,"uuid":"334773844","full_name":"fykosak/nette-orm","owner":"fykosak","description":"Light ORM extension for nette","archived":false,"fork":false,"pushed_at":"2024-11-02T15:53:33.000Z","size":129,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-06-23T05:06:01.341Z","etag":null,"topics":["nette-database","orm","package","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fykosak.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-01-31T22:50:29.000Z","updated_at":"2024-11-02T15:52:45.000Z","dependencies_parsed_at":"2024-11-01T13:17:13.872Z","dependency_job_id":"2a68a2c3-b919-4953-9bc1-f29ea0497912","html_url":"https://github.com/fykosak/nette-orm","commit_stats":{"total_commits":68,"total_committers":1,"mean_commits":68.0,"dds":0.0,"last_synced_commit":"6db16a6c4e63e649152c0f0d4ae5c3752825e31b"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/fykosak/nette-orm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fykosak%2Fnette-orm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fykosak%2Fnette-orm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fykosak%2Fnette-orm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fykosak%2Fnette-orm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fykosak","download_url":"https://codeload.github.com/fykosak/nette-orm/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fykosak%2Fnette-orm/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266419426,"owners_count":23925765,"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","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["nette-database","orm","package","php"],"created_at":"2024-11-11T16:16:10.564Z","updated_at":"2025-07-22T03:31:33.888Z","avatar_url":"https://github.com/fykosak.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nette ORM\n\n![GitHub branch checks state](https://img.shields.io/github/checks-status/fykosak/nette-orm/master)\n\u003cimg src=\"https://img.shields.io/badge/coverage-83%25-green\" /\u003e\n\n## install\n\n### Create ORM model\n\n```php\n\u003c?php \n/**\n * @property-read string name\n * @property-read int event_id\n * @property-read \\DateTimeInterface begin\n * @property-read \\DateTimeInterface end\n * @note better typehinting for your IDE\n */\nclass ModelEvent extends AbstractModel {\n    // you can define realtions\n    public function getParticipants(): GroupedSelection {\n        return $this-\u003erelated('participant', 'event_id');\n    }\n    // you can define own metods\n    public function __toArray(): array {\n        return [\n            'eventId' =\u003e $this-\u003eevent_id,          \n            'begin' =\u003e $this-\u003ebegin ? $this-\u003ebegin-\u003eformat('c') : null,\n            'end' =\u003e $this-\u003eend ? $this-\u003eend-\u003eformat('c') : null,          \n            'name' =\u003e $this-\u003ename,\n        ];\n    }\n}\n```\n\n### Create ORM service\n\n```php\n\u003c?php\n\nclass ServiceEvent extends AbstractService {\n\n    public function getNextEvents(): TypedTableSelection {\n        return $this-\u003egetTable()-\u003ewhere('begin \u003e NOW()');\n    }\n}\n```\n\n### Register extension\n```neon\norm:\n    \u003ctable_name\u003e:\n        service: 'FQN of service'\n        model: 'FQN of model'\n    \u003canother_table_name\u003e:\n        service: 'FQN of another service'\n        model: 'FQN of another model'\n\n```\n```neon\nextensions:\n    orm: Fykosak\\NetteORM\\ORMExtension\n```\n\n---\n## Examples\n\nTypedTableSelection is a regular selection you can use all methods like in nette DB Selection.\n\n```php \n$query= $sericeEvent-\u003egetNextEvent();\n$query-\u003ewhere('name','My cool event');\n```\n\nTypedTableSelection return ORM model instead of `ActiveRow`, but ORM model is a descendant of a `ActiveRow`.\n\n```php \n$query= $sericeEvent-\u003egetNextEvent();\nforeach($query as $event){\n$event // event is a ModelEvent\n}\n\n$model = $sericeEvent-\u003egetNextEvent()-\u003efetch(); // Model is a ModelEvent too.\n```\n\nTake care `GroupedSelection` still return `ActiveRow`, you can use static method `createFromActiveRow`\n\n```php \n$query= $sericeEvent-\u003egetParticipants();\nforeach($query as $row){\n// $row is a ActiveRow\n$participant = ModelParticipant::createFromActiveRow($row);\n}\n```\nDefine relations between Models by methods\n```php\nclass ModelParticipant extends AbstractModel {\n    // use ActiveRow to resolve relations and next create a Model.\n    public function getEvent(): ModelEvent {\n        return  ModelEvent::createFromActiveRow($this-\u003eevent);\n    }\n}\n```\n\nNow you can use `ReferencedAccessor` to access Model\n```php\n$myModel // any model that has define single method returned ModelEvent\n$modelEvent = ReferencedAccessor::accessModel($myModel,ModelEvent::class);\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffykosak%2Fnette-orm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffykosak%2Fnette-orm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffykosak%2Fnette-orm/lists"}