{"id":15024893,"url":"https://github.com/auraphp/aura.sqlschema","last_synced_at":"2025-08-22T00:32:22.757Z","repository":{"id":10870868,"uuid":"13157578","full_name":"auraphp/Aura.SqlSchema","owner":"auraphp","description":"Independent schema discovery tools for MySQL, PostgreSQL, SQLite, and Microsoft SQL Server.","archived":false,"fork":false,"pushed_at":"2016-04-29T13:48:57.000Z","size":458,"stargazers_count":40,"open_issues_count":5,"forks_count":14,"subscribers_count":14,"default_branch":"2.x","last_synced_at":"2024-12-20T06:07:11.009Z","etag":null,"topics":["aura","database","pdo","php","sql"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/auraphp.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGES.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-09-27T18:12:26.000Z","updated_at":"2024-12-16T06:49:02.000Z","dependencies_parsed_at":"2022-09-02T22:10:49.062Z","dependency_job_id":null,"html_url":"https://github.com/auraphp/Aura.SqlSchema","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/auraphp%2FAura.SqlSchema","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auraphp%2FAura.SqlSchema/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auraphp%2FAura.SqlSchema/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/auraphp%2FAura.SqlSchema/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/auraphp","download_url":"https://codeload.github.com/auraphp/Aura.SqlSchema/tar.gz/refs/heads/2.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230542289,"owners_count":18242332,"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":["aura","database","pdo","php","sql"],"created_at":"2024-09-24T20:01:08.227Z","updated_at":"2024-12-20T06:07:15.842Z","avatar_url":"https://github.com/auraphp.png","language":"PHP","readme":"# Aura.SqlSchema\n\nProvides facilities to read table names and table columns from a database\nusing a [PDO](http://php.net/PDO) connection.\n\n## Foreword\n\n### Installation\n\nThis library requires PHP 5.3 or later; we recommend using the latest available version of PHP as a matter of principle. It has no userland dependencies.\n\nIt is installable and autoloadable via Composer as [aura/sqlschema](https://packagist.org/packages/aura/sqlschema).\n\nAlternatively, [download a release](https://github.com/auraphp/Aura.SqlSchema/releases) or clone this repository, then require or include its _autoload.php_ file.\n\n### Quality\n\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/auraphp/Aura.SqlSchema/badges/quality-score.png?b=develop-2)](https://scrutinizer-ci.com/g/auraphp/Aura.SqlSchema/)\n[![Code Coverage](https://scrutinizer-ci.com/g/auraphp/Aura.SqlSchema/badges/coverage.png?b=develop-2)](https://scrutinizer-ci.com/g/auraphp/Aura.SqlSchema/)\n[![Build Status](https://travis-ci.org/auraphp/Aura.SqlSchema.png?branch=develop-2)](https://travis-ci.org/auraphp/Aura.SqlSchema)\n\nTo run the unit tests at the command line, issue `phpunit` at the package root. (This requires [PHPUnit][] to be available as `phpunit`.)\n\n[PHPUnit]: http://phpunit.de/manual/\n\nThis library attempts to comply with [PSR-1][], [PSR-2][], and [PSR-4][]. If\nyou notice compliance oversights, please send a patch via pull request.\n\n[PSR-1]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md\n[PSR-2]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md\n[PSR-4]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader.md\n\n### Community\n\nTo ask questions, provide feedback, or otherwise communicate with the Aura community, please join our [Google Group](http://groups.google.com/group/auraphp), follow [@auraphp on Twitter](http://twitter.com/auraphp), or chat with us on #auraphp on Freenode.\n\n\n## Getting Started\n\n### Instantiation\n\nInstantiate a driver-specific schema object with a matching\n[PDO](http://php.net/PDO) instance:\n\n```php\n\u003c?php\nuse Aura\\SqlSchema\\ColumnFactory;\nuse Aura\\SqlSchema\\MysqlSchema; // for MySQL\nuse Aura\\SqlSchema\\PgsqlSchema; // for PostgreSQL\nuse Aura\\SqlSchema\\SqliteSchema; // for Sqlite\nuse Aura\\SqlSchema\\SqlsrvSchema; // for Microsoft SQL Server\nuse PDO;\n\n// a PDO connection\n$pdo = new PDO(...);\n\n// a column definition factory\n$column_factory = new ColumnFactory();\n\n// the schema discovery object\n$schema = new MysqlSchema($pdo, $column_factory);\n?\u003e\n```\n\n### Fetching Table Lists\n\nTo get a list of tables in the database, issue `fetchTableList()`:\n\n```php\n\u003c?php\n$tables = $schema-\u003efetchTableList();\nforeach ($tables as $table) {\n    echo $table . PHP_EOL;\n}\n?\u003e\n```\n\n### Fetching Column Information\n\nTo get information about the columns in a table, issue `fetchTableCols()`:\n\n```php\n\u003c?php\n$cols = $schema-\u003efetchTableCols('table_name');\nforeach ($cols as $name =\u003e $col) {\n    echo \"Column $name is of type \"\n       . $col-\u003etype\n       . \" with a size of \"\n       . $col-\u003esize\n       . PHP_EOL;\n}\n?\u003e\n```\n\nEach column description is a `Column` object with the following properties:\n\n- `name`: (string) The column name\n\n- `type`: (string) The column data type.  Data types are as reported by the database.\n\n- `size`: (int) The column size.\n\n- `scale`: (int) The number of decimal places for the column, if any.\n\n- `notnull`: (bool) Is the column marked as `NOT NULL`?\n\n- `default`: (mixed) The default value for the column. Note that sometimes\n  this will be `null` if the underlying database is going to set a timestamp\n  automatically.\n\n- `autoinc`: (bool) Is the column auto-incremented?\n\n- `primary`: (bool) Is the column part of the primary key?\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fauraphp%2Faura.sqlschema","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fauraphp%2Faura.sqlschema","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fauraphp%2Faura.sqlschema/lists"}