PHP code example of fw3_for_old / builders

1. Go to this page and download the library: Download fw3_for_old/builders library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

fw3_for_old / builders example snippets


$table  = Table::factory('test_table');

$table->add(
    $table->column('primary_id')->int()->unsigned()->notNull()->autoIncrement()->comment('プライマリID'),
    $table->column('secondary_id')->int()->unsigned()->notNull()->comment('セカンダリID'),
    $table->column('name')->varchar(50)->defaultValue(null)->comment('名前'),
    $table->column('sex')->tinyint()->defaultValue(0)->comment('性別', array(
        'unknown'   => array(0, '未選択'),
        'male'      => array(1, '男性'),
        'female'    => array(2, '女性'),
        'other'     => array(3, 'その他'),
    )),
    $table->column('mail_address')->varchar(191)->notNull()->comment('連絡先メールアドレス'),
    $table->column('star')->int()->defaultValue(0)->comment('いいねの数'),
    $table->column('remarks')->text()->comment('備考'),
    $table->index(array('secondary_id', 'name')),
    $table->index('mail_address')->unique()
);

$table->primaryKey('primary_id');

$table->innoDb();

$table->utf8mb4();

$table->collation(Collation::factory()->utf8mb4()->japanese()->ci());

$table->comment('簡易DDLビルダーサンプル');

echo $table->build();

echo $table->build();

echo Table::factory('テーブル名')->add(function ($table) {
    return array(
        $table->column('primary_id')->int()
    );
})->build();