A library to abstract the mysql database schema rules


A library to abstract the mysql database schema rules

coverage build status


The installation of this library is made via composer. Download composer.phar from their website. Then add to your composer.json :

	"require": {
		"php-extended/php-db-schema-mysql": "^9"

Then run php composer.phar update to install this library. The autoloading of all classes of this library is made through composer's autoloader.

Basic Usage

This library can generate CREATE DATABASE statements.

use PhpExtended\DbSchema\MysqlTableFactory;
use PhpExtended\DbSchema\MysqlDialect;
use PhpExtended\DbSchema\MysqlTypeNumber;
use PhpExtended\DbSchema\MysqlTypeString;

$factory = new MysqlTableFactory();
$dialect = new MysqlDialect();


// <tableColumnId> INT(11) NOT NULL AUTO_INCREMENT COMMENT 'The primary key'
$factory->addColumn('<tableColumnId>', MysqlTypeNumber::INT(), 11, null, null, false, true, 'The primary key');
// <nameColumn> VARCHAR(255) NOT NULL COMMENT 'The name of the <xxx>'
$factory->addColumn('<nameColumn>', MysqlTypeString::VARCHAR(), 255, null, null, false, false, 'The name of the <xxx>');

$sql = $dialect->showCreateTable($factory->getTable());	// CREATE TABLE ...


MIT (See license file).