degami/sql-schema

Library for describe of the database schema.

dev-master 2024-10-26 14:32 UTC

This package is auto-updated.

Last update: 2025-02-26 15:24:56 UTC


README

Library for describe of the database schema.

forked from : https://github.com/czproject/sql-schema

Installation

composer require degami/sql-schema

Degami\SqlSchema requires PHP 7.2 or later.

Usage

use Degami\SqlSchema\Index;
$schema = new Degami\SqlSchema\Schema;

$table = $schema->addTable('book');
$table->addColumn('id', 'INT', NULL, array('UNSIGNED'));
      ->addColumn('name', 'VARCHAR', array(200));
      ->addColumn('author_id', 'INT', NULL, array('UNSIGNED'));
      ->addIndex(NULL, 'id', Index::TYPE_PRIMARY);
      ->addIndex('name_author_id', array('name', 'author_id'), Index::TYPE_UNIQUE);

foreach( $schema->getTables() as $table ) {
    echo $table->showCreate()."\n";
}

License: New BSD License