68 lines
1.9 KiB
PHP
68 lines
1.9 KiB
PHP
|
|
<?php defined('BASEPATH') OR exit('No direct script access allowed');
|
||
|
|
/*Powered By: Manaknightdigital Inc. https://manaknightdigital.com/ Year: 2021*/
|
||
|
|
/**
|
||
|
|
* professor Migration
|
||
|
|
*
|
||
|
|
* @copyright 2019 Manaknightdigital Inc.
|
||
|
|
* @link https://manaknightdigital.com
|
||
|
|
* @license Proprietary Software licensing
|
||
|
|
* @author Ryan Wong
|
||
|
|
*/
|
||
|
|
class Migration_professor extends CI_Migration {
|
||
|
|
|
||
|
|
public function up()
|
||
|
|
{
|
||
|
|
$this->dbforge->add_field([ 'id' => array('type' => 'INT','constraint' => 11,'unsigned' => TRUE,'auto_increment' => TRUE),
|
||
|
|
'name' => array('type' => 'VARCHAR', 'constraint' => '255'),
|
||
|
|
'status' => array('type' => 'INT', 'constraint' => 11, 'null' => TRUE),
|
||
|
|
'created_at' => array('type' => 'DATE', 'null' => TRUE),
|
||
|
|
'updated_at' => array('type' => 'DATETIME', 'null' => TRUE)]);
|
||
|
|
$this->dbforge->add_key('id', TRUE);
|
||
|
|
$this->dbforge->create_table('professor');
|
||
|
|
$this->seed_data();
|
||
|
|
}
|
||
|
|
|
||
|
|
public function down()
|
||
|
|
{
|
||
|
|
$this->dbforge->drop_table('professor');
|
||
|
|
}
|
||
|
|
public function seed_data()
|
||
|
|
{
|
||
|
|
$data = [
|
||
|
|
[
|
||
|
|
'name' => 'Toni Kroos',
|
||
|
|
'status' => 1,
|
||
|
|
'created_at' => date('Y-m-j'),
|
||
|
|
'updated_at' => date('Y-m-j H:i:s'),
|
||
|
|
],
|
||
|
|
[
|
||
|
|
'name' => 'Carlos Casemiro',
|
||
|
|
'status' => 1,
|
||
|
|
'created_at' => date('Y-m-j'),
|
||
|
|
'updated_at' => date('Y-m-j H:i:s'),
|
||
|
|
],
|
||
|
|
[
|
||
|
|
'name' => 'Luka Modric',
|
||
|
|
'status' => 1,
|
||
|
|
'created_at' => date('Y-m-j'),
|
||
|
|
'updated_at' => date('Y-m-j H:i:s'),
|
||
|
|
],
|
||
|
|
|
||
|
|
];
|
||
|
|
|
||
|
|
foreach ($data as $k => $seed )
|
||
|
|
{
|
||
|
|
foreach ($seed as $key => $value)
|
||
|
|
{
|
||
|
|
$seed[$key] = '\'' . addslashes($value) . '\'';
|
||
|
|
}
|
||
|
|
|
||
|
|
$row = array_values($seed);
|
||
|
|
array_unshift($row, (string)($k + 1));
|
||
|
|
$sql = 'INSERT INTO professor VALUES ' . '(' . implode(',', $row) . ')';
|
||
|
|
error_log($sql);
|
||
|
|
$this->db->query($sql);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|