PHP Classes

File: gii/default_data/data_batch.php

Recommend this page to a friend!
  Classes of Insolita   YII2 Migrik   gii/default_data/data_batch.php   Download  
File: gii/default_data/data_batch.php
Role: Example script
Content type: text/plain
Description: Example script
Class: YII2 Migrik
Create migration files for applications using YII2
Author: By
Last change:
Date: 1 year ago
Size: 947 bytes
 

Contents

Class file image Download
<?php
/**
 * This view is used by console/controllers/MigrateController.php
 * The following variables are available in this view:
 */
/** @var $migrationName string the new migration class name
 * @var insolita\migrik\gii\DataGenerator $generator
 */

echo "<?php\n";
?>

use yii\db\Schema;
use yii\db\Migration;

class <?= $migrationName ?> extends Migration
{

    public function init()
    {
        $this->db = 'db';
        parent::init();
    }

    public function safeUp()
    {
        $this->batchInsert('<?= ($generator->usePrefix)?$generator->tableAlias:$generator->tableName ?>',
                           ["<?= implode('", "', $generator->tableColumns) ?>"],
                            <?= \yii\helpers\VarDumper::export($generator->rawData) ?>

        );
    }

    public function safeDown()
    {
        //$this->truncateTable('<?= ($generator->usePrefix)?$generator->tableAlias:$generator->tableName ?> CASCADE');
    }
}