![]() |
I've been trying to follow the process for creating a new database, as detailed here: https://codeigniter4.github.io/userguide...se-db-name
PHP Code: <?php What am I doing wrong?
~ Dave
You can also pass another database group name to the DB Forge loader, in case the database you want to manage isn’t the default one:
PHP Code: $this->myforge = \Config\Database::forge('other_db'); You need to create a new database config for the database you want to use or it will default to the original one. What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Thanks!
Your response got me thinking and it occurred to me that my database user did not have permissions to create the new database. Once I corrected this, the Model worked as expected... Many thanks!
~ Dave
Your welcome.
What did you Try? What did you Get? What did you Expect?
Joined CodeIgniter Community 2009. ( Skype: insitfx )
Just to add that creating tables for the new database is not really straightforward and the code above generates an error when fields and tables are added: "InvalidArgumentException D8 is not a valid database connection group."
It seems that the new database needs an entry in \Config\Databases.php to establish a connection. If I simply put "$this->db->simpleQuery('USE '.$dbName);", then the tables are added without error. Hope this helps anyone seeking to do the same...
~ Dave
|
Welcome Guest, Not a member yet? Register Sign In |