• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
DBForge table creation error 1046

#1
[eluser]BirdieNZ[/eluser]
I want my application to be able to re-create a database (by deleting and creating it if it already exists, or just creating it if it doesn't). I have used dbforge to drop the database and create a new one, which works correctly.

Code:
$this->dbforge->drop_database('mydatabase');
$this->dbforge->create_database('mydatabase');

Inside database.php, the default DB name is mydatabase (the same name).

However, when I add a table to the database it fails, suggesting that there is no database selected (and is unable to select the database).
Code:
$this->load->database();
$fields = array(
'category_id' => array(
        'type' => 'INT',
        'constraint' => 5,
        'unsigned' => TRUE,
        'auto_increment' => TRUE
       ),
'category_title' => array(
        'type' => 'VARCHAR',
        'constraint' => '100',
       ),
);
$this->dbforge->add_field($fields);
$this->dbforge->add_key('category_id', TRUE);
$this->dbforge->create_table('category');

Why is this and what can I do to fix it?


Messages In This Thread
DBForge table creation error 1046 - by El Forum - 09-10-2014, 04:44 PM
DBForge table creation error 1046 - by El Forum - 09-11-2014, 01:37 PM
DBForge table creation error 1046 - by El Forum - 09-11-2014, 01:45 PM
DBForge table creation error 1046 - by El Forum - 09-11-2014, 04:11 PM
DBForge table creation error 1046 - by El Forum - 09-11-2014, 06:27 PM
DBForge table creation error 1046 - by El Forum - 09-11-2014, 07:02 PM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.