{"id":15024196,"url":"https://github.com/digitaldreams/dbreader","last_synced_at":"2025-04-12T06:32:45.610Z","repository":{"id":56968794,"uuid":"103200528","full_name":"digitaldreams/dbreader","owner":"digitaldreams","description":"Database Reader","archived":false,"fork":false,"pushed_at":"2017-09-19T01:31:35.000Z","size":21,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-31T10:36:25.751Z","etag":null,"topics":["mysql-database","php"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"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/digitaldreams.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":"2017-09-12T00:05:35.000Z","updated_at":"2024-05-28T15:19:03.000Z","dependencies_parsed_at":"2022-08-21T10:20:41.268Z","dependency_job_id":null,"html_url":"https://github.com/digitaldreams/dbreader","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitaldreams%2Fdbreader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitaldreams%2Fdbreader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitaldreams%2Fdbreader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitaldreams%2Fdbreader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/digitaldreams","download_url":"https://codeload.github.com/digitaldreams/dbreader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223502362,"owners_count":17155938,"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":["mysql-database","php"],"created_at":"2024-09-24T19:59:55.757Z","updated_at":"2024-11-07T11:05:11.831Z","avatar_url":"https://github.com/digitaldreams.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"For some kind of automation tools we need to know database constraints like tables, fields and its indexes. But its very hard and painful to get this information from directly database. This tool will make this task super simple.\n## Installation\nAdd this line on your composer.json\n```javascript\n    \"require\":{\n        \"digitaldream/dbreader\":\"~1.0\"\n    }\n```\n## Settings\nSet Database information on top of page. \n```php\n\\DbReader\\Database::settings([\n    'database' =\u003e \"YOUR_DATABASE_NAME\",\n    'username' =\u003e \"YOUR_DATABASE_USERNAME\",\n    'password' =\u003e \"YOUR_DATABSE_PASSWORD\",\n    // or you can just assign a pdo object via\n    // 'pdo'=\u003e $your_pdo_object\n    //Below are optional columns\n    'manualRelations' =\u003e [\n        'tours.start_location' =\u003e 'locations.id',\n        'tours.end_location' =\u003e 'locations.id'\n    ],\n    'ignore' =\u003e [],\n    'protectedColumns' =\u003e ['id', 'created_at', 'updated_at'],\n    'files' =\u003e ['users.avatar']\n]);\n\n```\n### Database\n```php\n$db=new \\DbReader\\Database();\nprint_r($db-\u003etables()); // return array of tables\n// You can also access a individual table object\nprint_r($db-\u003eusers); // It will return \\DbReader\\Table Object\n// Even further\nprint_r($db-\u003eusers-\u003eid) // It will return \\DbReader\\Column Object\n```\n### Table\n```php\n$user=new \\DbReader\\Table('users');\nprint_r($user-\u003ecolumns()) // return all columns as array of StdClass\nprint_r($user-\u003ecolumnClasses()) // return list of Column Class object as array. Most preferable rather than columns()\nprint_r($user-\u003erelations()); // return all the Foreign Relation of a given table. \nprint_r($user-\u003eindexes()); // return all the Indexes of given table. \n```\n### Column\n```php\n$user=new \\DbReader\\Table('users');\necho $user-\u003eemail-\u003ename(); // name of the column\necho $user-\u003eemail-\u003etype(); // type Column data type enum, int, text etc\necho $user-\u003eemail-\u003elength(); //  return length e.g. 255 for varchar\necho $user-\u003eemail-\u003edefaultValue(); \necho $user-\u003eemail-\u003eisPk();\necho $user-\u003eemail-\u003eisUnique();\necho $user-\u003eemail-\u003eisNull();\necho $user-\u003eemail-\u003eisForeign();\n```\n\n*N.B*:\nThis is a submodule of [LaraCrud](https://github.com/digitaldreams/laracrud) and\nonly Support Mysql Database now.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitaldreams%2Fdbreader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdigitaldreams%2Fdbreader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitaldreams%2Fdbreader/lists"}