mysql - Codeigniter showing error: No database selected -


i using codeigniter's dbforge class create database , table within database.

here code:

if ($this->dbforge->create_database('new_db')) {      $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);      $this->dbforge->create_table('blog', true); } 

the above mentioned code written inside index function of controller. when following code executed, shows error as, no database selected. have ant idea why happening. appreciated.

you need specify

 $db['default']['database'] = "new_db";  

in database.php


Comments