[eluser]mad82[/eluser]
Hi I got a problem when trying to create table using dbforge, the below is the error message I got, Any help to resolve the problem is greatly appreciated.
Quote:An Error Was Encountered
Field information is required for that operation.
Below are the two files I used
Code:
class Fileload extends CI_Controller
{
function _construct()
{
parent::_construct();
$this->load->helper(array('form','url'));
}
function index()
{
$config['hostname'] = "localhost";
$config['username'] = "root";
$config['password'] = "test";
$config['database'] = "login-db";
$config['dbdriver'] = "mysql";
$config['dbprefix'] = "";
$config['pconnect'] = FALSE;
$config['db_debug'] = TRUE;
$config['cache_on'] = FALSE;
$config['cachedir'] = "";
$config['char_set'] = "utf8";
$config['dbcollat'] = "utf8_general_ci";
$this->load->database($config);
$this->load->dbforge();
$this->load->view('view_data');
}
}
?>
Here is the second file
Code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Welcome to CodeIgniter</title>
</head>
<body>
<? php
$fields = array(
'blog_id' => array(
'type' => 'INT',
'constraint' => 5,
'unsigned' => TRUE,
'auto_increment' => TRUE
),
'blog_title' => array(
'type' => 'VARCHAR',
'constraint' => '100',
),
'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);
if($this->dbforge->create_table('blog'))
{
echo"table created";
}
?>
</body>
</html>