Welcome Guest, Not a member yet? Register   Sign In
Catch 22 using DB_Forge
#1

I wrote a database migration tool using CI's DB_Forge
It starts like this:
$this->load->dbforge();
# Create database if not exists
$this->dbforge->create_database("test"TRUE);


If my database is already created, CI could connect to it, and run this query.
However if there is no DB (which is why I need the migration tool), it will say "You have not selected a database type to connect to."

Catch 22:
To execute a "CREATE DATABASE" query, I need to have a valid database to connect to first.
To have a valid database, I need to execute "CREATE DATABASE" query

My mysql connection is as follows: (no database selected)

[
  "dsn"  => "",
  "hostname" => DB_HOSTNAME,
  "username" => DB_USERNAME,
  "password" => DB_PASSWORD,
  "port"     => DB_PORT,
  "dbdriver" => "mysqli",
  "dbprefix" => "",
  "pconnect" => TRUE,
  "db_debug" => (ENVIRONMENT !== "production"),
  "cache_on" => FALSE,
  "cachedir" => "",
  "char_set" => "utf8",
  "dbcollat" => "utf8_unicode_ci",
  "swap_pre" => "",
  "encrypt" => FALSE,
  "compress" => FALSE,
  "stricton" => FALSE,
  "failover" => [],
  "save_queries" => TRUE
]


So my questions are:
- Is this intended?
- Is there a quick fix for this?
- Is there maybe a different way to execute my query outside of this DB connection?
Reply


Messages In This Thread
Catch 22 using DB_Forge - by AmitMY - 10-24-2016, 07:10 AM
RE: Catch 22 using DB_Forge - by AmitMY - 10-26-2016, 09:40 AM
RE: Catch 22 using DB_Forge - by zknight - 10-26-2016, 10:07 AM
RE: Catch 22 using DB_Forge - by AmitMY - 10-26-2016, 10:17 AM



Theme © iAndrew 2016 - Forum software by © MyBB