Skip to content

Instantly share code, notes, and snippets.

@GDmac
Created November 11, 2012 06:26
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save GDmac/4053937 to your computer and use it in GitHub Desktop.
CI 3.dev DB-Forge
<?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