{"id":19357743,"url":"https://github.com/joomla-framework/model","last_synced_at":"2025-04-23T11:30:30.601Z","repository":{"id":7094556,"uuid":"8385840","full_name":"joomla-framework/model","owner":"joomla-framework","description":"Joomla Framework Model Package","archived":false,"fork":false,"pushed_at":"2025-04-20T10:09:08.000Z","size":5455,"stargazers_count":2,"open_issues_count":0,"forks_count":7,"subscribers_count":12,"default_branch":"3.x-dev","last_synced_at":"2025-04-20T11:22:45.989Z","etag":null,"topics":["joomla","joomla-framework","model","mvc","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-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joomla-framework.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"joomla","custom":"https://community.joomla.org/sponsorship-campaigns.html"}},"created_at":"2013-02-24T03:27:18.000Z","updated_at":"2025-04-01T09:42:53.000Z","dependencies_parsed_at":"2025-04-21T10:45:58.497Z","dependency_job_id":null,"html_url":"https://github.com/joomla-framework/model","commit_stats":{"total_commits":106,"total_committers":16,"mean_commits":6.625,"dds":0.4339622641509434,"last_synced_commit":"06ef6c628cff86c70a8d220106d1d3cc14037ee6"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joomla-framework%2Fmodel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joomla-framework%2Fmodel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joomla-framework%2Fmodel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joomla-framework%2Fmodel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joomla-framework","download_url":"https://codeload.github.com/joomla-framework/model/tar.gz/refs/heads/3.x-dev","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250424926,"owners_count":21428469,"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":["joomla","joomla-framework","model","mvc","php"],"created_at":"2024-11-10T07:09:01.900Z","updated_at":"2025-04-23T11:30:30.322Z","avatar_url":"https://github.com/joomla-framework.png","language":"PHP","funding_links":["https://github.com/sponsors/joomla","https://community.joomla.org/sponsorship-campaigns.html"],"categories":[],"sub_categories":[],"readme":"# The Model Package [![Build Status](https://ci.joomla.org/api/badges/joomla-framework/model/status.svg?ref=refs/heads/3.x-dev)](https://ci.joomla.org/joomla-framework/model)\n\n[![Latest Stable Version](https://poser.pugx.org/joomla/model/v/stable)](https://packagist.org/packages/joomla/model)\n[![Total Downloads](https://poser.pugx.org/joomla/model/downloads)](https://packagist.org/packages/joomla/model)\n[![Latest Unstable Version](https://poser.pugx.org/joomla/model/v/unstable)](https://packagist.org/packages/joomla/model)\n[![License](https://poser.pugx.org/joomla/model/license)](https://packagist.org/packages/joomla/model)\n\n## Interfaces\n\n### `Model\\ModelInterface`\n\n`Model\\ModelInterface` is an interface that requires a class to be implemented with a `getState` and a `setState` method.\n\n## Classes\n\n# `Model\\AbstractModel`\n\n#### Construction\n\nThe contructor for a new `Model\\AbstractModel` object takes an optional `Registry` object that defines the state of the model. If omitted, an empty `Registry` object will be assigned automatically.\n\n#### Usage\n\nThe `Model\\AbstractModel` class is abstract. All requirements of the interface are already satisfied by the base class.\n\n```php\n\nnamespace MyApp;\n\nuse Joomla\\Model\\AbstractModel;\n\n/**\n * My custom model.\n *\n * @pacakge  Examples\n *\n * @since   1.0\n */\nclass MyModel extends AbstractModel\n{\n  /**\n\t * Get the time.\n\t *\n\t * @return  integer\n\t *\n\t * @since   1.0\n\t */\n\tpublic function getTime()\n\t{\n\t\treturn time();\n\t}\n}\n```\n\n# `Model\\AbstractDatabaseModel`\n\n#### Construction\n\n`Model\\AbstractDatabaseModel` is extended from `Model\\AbstractModel` and the contructor takes a required `Database\\DatabaseDriver` object and an optional `Registry` object.\n\n#### Usage\n\nThe `Model\\AbstractDatabaseModel` class is abstract so cannot be used directly. It forms a base for any model that needs to interact with a database.\n\n```php\n\nnamespace MyApp\n\nuse Joomla\\Model;\nuse Joomla\\Database;\n\n/**\n * My custom database model.\n *\n * @package  Examples\n *\n * @since   1.0\n */\nclass MyDatabaseModel extends Model\\AbstractDatabaseModel\n{\n\t/**\n\t * Get the content count.\n\t *\n\t * @return  integer\n\t *\n\t * @since   1.0\n\t * @throws  RuntimeException on database error.\n\t */\n\tpublic function getCount()\n\t{\n\t\t// Get the query builder from the internal database object.\n\t\t$q = $this-\u003edb-\u003egetQuery(true);\n\n\t\t// Prepare the query to count the number of content records.\n\t\t$q-\u003eselect('COUNT(*)')-\u003efrom($q-\u003eqn('#__content'));\n\n\t\t$this-\u003edb-\u003esetQuery($q);\n\n\t\t// Execute and return the result.\n\t\treturn $this-\u003edb-\u003eloadResult();\n\t}\n}\n\ntry\n{\n\t$driver = Database\\DatabaseFactory::getInstance()-\u003egetDriver('mysqli');\n\t$model = new MyDatabaseModel($driver);\n\t$count = $model-\u003egetCount();\n}\ncatch (RuntimeException $e)\n{\n\t// Handle database error.\n}\n```\n\n\n## Installation via Composer\n\nAdd `\"joomla/model\": \"~3.0\"` to the require block in your composer.json and then run `composer install`.\n\n```json\n{\n\t\"require\": {\n\t\t\"joomla/model\": \"~3.0\"\n\t}\n}\n```\n\nAlternatively, you can simply run the following from the command line:\n\n```sh\ncomposer require joomla/model \"~3.0\"\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoomla-framework%2Fmodel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoomla-framework%2Fmodel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoomla-framework%2Fmodel/lists"}