https://github.com/czproject/sql-schema
Library for describe of the database schema.
https://github.com/czproject/sql-schema
database-schema php sql-schema
Last synced: 3 months ago
JSON representation
Library for describe of the database schema.
- Host: GitHub
- URL: https://github.com/czproject/sql-schema
- Owner: czproject
- License: other
- Created: 2017-01-21T17:15:05.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2023-07-27T10:25:30.000Z (over 2 years ago)
- Last Synced: 2025-02-05T16:04:30.764Z (12 months ago)
- Topics: database-schema, php, sql-schema
- Language: PHP
- Homepage:
- Size: 48.8 KB
- Stars: 6
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- Funding: .github/FUNDING.yml
- License: license.md
Awesome Lists containing this project
README
# CzProject\SqlSchema
[](https://github.com/czproject/sql-schema/actions)
[](https://packagist.org/packages/czproject/sql-schema)
[](https://github.com/czproject/sql-schema/releases)
[](https://github.com/czproject/sql-schema/blob/master/license.md)
Library for describe of the database schema.
## Installation
[Download a latest package](https://github.com/czproject/sql-schema/releases) or use [Composer](http://getcomposer.org/):
```
composer require czproject/sql-schema
```
CzProject\SqlSchema requires PHP 8.0 or later.
## Usage
``` php
use CzProject\SqlSchema\Index;
$schema = new CzProject\SqlSchema\Schema;
$table = $schema->addTable('book');
$table->addColumn('id', 'INT', NULL, array('UNSIGNED'));
$table->addColumn('name', 'VARCHAR', array(200));
$table->addColumn('author_id', 'INT', NULL, array('UNSIGNED'));
$table->addIndex(NULL, 'id', Index::TYPE_PRIMARY);
$table->addIndex('name_author_id', array('name', 'author_id'), Index::TYPE_UNIQUE);
$schema->getTables();
```
------------------------------
License: [New BSD License](license.md)
Author: Jan Pecha, https://www.janpecha.cz/