Dynamic database creation |
[eluser]crazypolecat[/eluser]
Hello, CodeIgniter's Database library is powerful and I like its ease of use a lot, but for a particular project I need to dynamically create new databases. Getting it to work is no problem. I use mysql_connect and mysql_query, but I wonder if this is the best approach in CodeIgniter? I assume that the Database class cannot be used for this kind of tasks. Thanks.
[eluser]bl00dshooter[/eluser]
Use the database forge class: http://ellislab.com/codeigniter/user-gui...forge.html
[eluser]crazypolecat[/eluser]
I noticed to issues when reading the user guide on dbforge. When you create a table with dbforge, how does it know to which table it should add the table? Also, you can add a second parameter when creating a table to see if the table already exists, but this option is not available for creating a database. This seems odd or am I overlooking something? Thanks.
[eluser]cideveloper[/eluser]
This code solves both your problems. Code: $this->load->dbforge();
[eluser]crazypolecat[/eluser]
This is indeed what I was looking for. I didn't know about the dot-notation in the create_table method. That's a handy feature! Thanks a lot. |
Welcome Guest, Not a member yet? Register Sign In |