2017 © Pedro Peláez
 

library yii2-table-builder

Yii2 table builder

image

infinitydevphp/yii2-table-builder

Yii2 table builder

  • Monday, September 19, 2016
  • by infinitydevphp
  • Repository
  • 1 Watchers
  • 1 Stars
  • 191 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Yii2 table generator class with migration template

  • Install
php composer.phar require infinitydevphp/yii2-table-builder "1.0"

Field config params

Param name type Description Required
name string Field name in database true
type string One of definition type in yii\db\Schema true
length integer Length field for string numeric data false
default mixed Default value false
is_not_null boolean Is not null field false
unsigned boolean Unsigned number false
related_table string Related table name false
related_field string Related field name false
fk_name string Foreign key name false

Usages

  • Create table
<?php 
use infinitydevphp\tableBuilder\TableBuilder;
use \yii\db\Schema;

$class = new TableBuilder([
    'tableName' => 'order',
    'fields' => [
        [
            'name' => 'id',
            'type' => Schema::TYPE_PK,
        ],
        [
            'name' => 'date_created',
            'type' => Schema::TYPE_TIMESTAMP,
        ],
        [
            'name' => 'price',
            'type' => Schema::TYPE_INTEGER,
        ],
        [
            'name' => 'good_id',
            'type' => Schema::TYPE_INTEGER,
        ],
        [
            'name' => 'user_id',
            'type' => Schema::TYPE_INTEGER,
            'length' => 11,
            'related_field' => 'user_id',
            'related_table' => 'order',
        ],
    ],
]);
$resultRelations = $class->runQuery();
  • Create migration from template
$class = new TableBuilderTemplateMigration([
    'tableName' => 'order'
]);
$migrationTemplateString = $class->runQuery();

The Versions

19/09 2016

dev-master

9999999-dev https://github.com/infinitydevphp/yii2-table-builder

Yii2 table builder

  Sources   Download

MIT

The Requires

 

by Avatar infinitydevphp