Reputation: 61
I try to create a table with codeigniter in mysql DB with following code:
$posts_fields=array(
'id'=>array('type' => 'INT','constraint' => 5,'unsigned' => TRUE),
'title'=>array('type' =>'VARCHAR','constraint' => 100),
'content'=>array('type'=>'text'),
'create_time'=>array('type'=>'INT','constraint'=>12));
$this->dbforge->add_field($posts_fields);
$this->dbforge->create_table('posts');
but anytime get error "NO DATABASE SELECTED".
how can I select a database to create tables in it?? (this database is not default database)
Upvotes: 2
Views: 6417
Reputation: 11
database.php Declare database name in the database.php
This may solve your error!
Upvotes: 1
Reputation: 1864
You can have a look at Codeigniter showing error: No database selected
If you are using different database then use following,
$this->db->query('use db2');
and then put your code.
Upvotes: 3