CI 3.dev DB-Forge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Welcome2 extends CI_Controller { | |
public function forge() | |
{ | |
$this->output->enable_profiler(TRUE); | |
$this->load->database(); | |
$this->load->dbforge(); | |
$this->dbforge->add_field(array( | |
'session_id' => array( | |
'type' => 'VARCHAR', | |
'constraint' => 80, | |
'default' => '0', | |
'null' => FALSE, | |
), | |
'ip_address' => array( | |
'type' => 'VARCHAR', | |
'constraint' => 45, | |
'default' => '0', | |
'null' => FALSE, | |
), | |
'user_agent' => array( | |
'type' => 'VARCHAR', | |
'constraint' => 120, | |
'null' => FALSE, | |
), | |
'last_activity' => array( | |
'type' => 'INT', | |
'constraint' => '10', | |
'unsigned' => TRUE, | |
'default' => 0, | |
'null' => FALSE, | |
), | |
'user_data' => array( | |
'type' => 'TEXT', | |
'null' => FALSE, | |
), | |
)); | |
// Primary | |
$this->dbforge->add_key('session_id', TRUE); | |
// Other | |
$this->dbforge->add_key('last_activity'); | |
// Run Forge | |
$this->dbforge->create_table('ci_sessions'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment