<?php
defined('BASEPATH') OR exit('No direct script access allowed');
class Table_model extends CI_Model {
public function __construct()
{
$this->load->database();
$this->load->dbforge();
}
public function create_table()
{
$fields = array(
'blog_id' => array(
'type' => 'INT',
'constraint' => 5,
'unsigned' => TRUE,
'auto_increment' => TRUE
),
'blog_title' => array(
'type' => 'VARCHAR',
'constraint' => '100',
'unique' => TRUE,
),
'blog_author' => array(
'type' =>'VARCHAR',
'constraint' => '100',
'default' => 'King of Town',
),
'blog_description' => array(
'type' => 'TEXT',
'null' => TRUE,
),
);
$this->dbforge->add_field($fields);
$this->dbforge->add_key('blog_id',true);
return $this->dbforge->create_table('mytable',TRUE);
}
}