{"id":30450279,"url":"https://github.com/nochso/arrow","last_synced_at":"2025-08-23T13:26:41.350Z","repository":{"id":88156757,"uuid":"44998196","full_name":"nochso/Arrow","owner":"nochso","description":null,"archived":false,"fork":false,"pushed_at":"2015-10-31T12:39:11.000Z","size":135,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-02-27T06:36:05.887Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://github.com/fastpress/Arrow","language":"PHP","has_issues":false,"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/nochso.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":"2015-10-26T21:23:46.000Z","updated_at":"2023-03-07T20:36:50.198Z","dependencies_parsed_at":"2023-03-07T20:36:50.186Z","dependency_job_id":null,"html_url":"https://github.com/nochso/Arrow","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"purl":"pkg:github/nochso/Arrow","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nochso%2FArrow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nochso%2FArrow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nochso%2FArrow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nochso%2FArrow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nochso","download_url":"https://codeload.github.com/nochso/Arrow/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nochso%2FArrow/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271749048,"owners_count":24814115,"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-08-23T02:00:09.327Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","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":[],"created_at":"2025-08-23T13:26:24.533Z","updated_at":"2025-08-23T13:26:41.343Z","avatar_url":"https://github.com/nochso.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Arrow\nMix of active record and fluent query builder that is easily extensible.\n\nSupports:\n- MySQL / MariaDB\n- SQLite\n- PostgreSQL\n- MS SQL (missing support for OFFSET)\n\n## Setup / connection\nCreate a new instance and use the `connect()` method that is compatible with `\\PDO`'s constructor:\n```php\n$orm = new Fastpress\\Arrow\\ORM();\n$orm-\u003econnect('sqlite:/db.sqlite');\n$orm-\u003econnect('mysql:host=localhost;dbname=mydb', 'username', 'password');\n$orm-\u003econnect('mysql:host=localhost;dbname=mydb', 'username', 'password', [\\PDO::ATTR_CASE =\u003e \\PDO::CASE_LOWER]);\n```\nYou have direct access to the `\\PDO` connection:\n```php\n$orm-\u003epdo-\u003ebeginTransaction();\n```\nThe newest instance of `ORM` is kept via static property `Fastpress\\Arrow\\ORM::$instance` \n\n## Models\n### Defining your own models\nThe fastest way to get started is extending `Fastpress\\Arrow\\FluentModel`:\n```php\nclass User extends Fastpress\\Arrow\\FluentModel { ... }\n```\nBy default the class name will be converted to lower-case snake_case, e.g. class `UserRole` becomes table name `user_role`. The default primary key name is `id`. However you can override both when extending any Model:\n```php\nclass User extends Fastpress\\Arrow\\FluentModel {\n    public function getTableName() {\n        return 'users';\n    }\n    public function getPrimaryKeyName() {\n        return 'id';\n    }\n}\n```\n\n### Fluent interface\nYou can already access the database using your model and a fluent query interface:\n```php\n$userQuery = new User();\n# Returns a list of `User` objects whose names start with \"Jo\"\n$userList = $userQuery-\u003elike('name', 'Jo%')-\u003eall();\nforeach ($userList as $user) {\n    echo $user-\u003ename . \"\\n\";\n}\n```\nFor more information about the fluent interface, take a look at `Fastpress\\Arrow\\Builder\\FluentBuilderTrait`.\n\n### Active Record\nEach model has ActiveRecord style methods to save, update and delete rows:\n```php\n$user = new User();\n$user-\u003ename = 'John';\n$user-\u003esave();   // INSERT new row\necho $user-\u003eid;  // Primary key was set by save()\n\n$user-\u003ename = 'Jane';\n$user-\u003eupdate(); // UPDATE existing row\n$user-\u003edelete(); // DELETE existing row\n```\n\n### Avoiding models\nIf you choose not to create or use model classes for each table, you can use the DynamicFluentModel:\n```php\n// Create a model for any table on the fly:\n$user = DynamicFluentModel::create('user');\n\n// which is a shortcut for:\n$user = new DynamicFluentModel();\n$user-\u003ewithTable('user', 'id', $columns);\n// The last 2 parameters default to 'id' and array()\n\n$user-\u003ename = 'John';\n$user-\u003esave();\n\n// Alternatively:\n$user = DynamicFluentModel::create('user', 'id', ['name' =\u003e 'Sweet Dee']);\n$user-\u003esave();\n\n$user-\u003ename = 'Jane';\n$user-\u003eupdate();\n\n$jane = $user-\u003ewhere('id', $user-\u003eid)-\u003eone();\n// $jane-\u003ename == 'Jane'\n```\n\n### Structure\nThe base class for models is `Model`. When extending this, all you get is a model definition and the Active Record functionality.\n\n* **Model** - Base table definition including Active Record methods **without** fluent methods.\n  * **FluentModel** - Extends directly from Model, pulling in the FluentBuilderTrait for fluent query building.\n    * **DynamicFluentModel** - Can be used to create a `FluentModel` on the fly without actually declaring it. See section \"Avoiding models\" also.\n    ```php\n    $simpleModel = new User(); # extends directly from Model\n    $simpleModel-\u003eis_deleted = true;\n    $model = new DynamicFluentModel();\n    $model-\u003ewithModel($simpleModel);\n    # Updates is_deleted for all rows where name is 'Anonymous'\n    $rowCount = $model-\u003ewhere('name', 'Anonymous')-\u003eupdateAll();\n    ```\n\nIt is essentially up to you what features the models support.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnochso%2Farrow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnochso%2Farrow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnochso%2Farrow/lists"}