DB Forge with DSN Conn |
[eluser]dave80[/eluser]
Would anyone know is this is possible at all? class Bla bla extends Controller{ ....... .. $dsn = 'mysql://username:password@localhost/databse_other_then_whats_in_config'; $DB1 = $this->load->database($dsn, TRUE, TRUE); $fields = array( 'users' => array( 'type' => 'VARCHAR', 'constraint' => '100', ), ); $DB1->dbforge->add_field($fields); $DB1->dbforge->create_table('table_name', TRUE); Im assuming dbforge functions only works with $this->db
[eluser]dave80[/eluser]
To add on my previous post, I think the $this->dbforge->create_database() function should be removed. As I can not see how you can access the database this function just created. Hence thats why I am trying to get it to work using the DSN connection. All I want to do is create a database and fill it up with tables. Should I be using an external script for this whole procedure, or am I completely mistaken about the whole dbforge subject?
[eluser]TheFuzzy0ne[/eluser]
Your class name should not contain a whitespace. (just kidding). Also not sure what purpose the third parameter serves in $this->load->database(). I don't see why it shouldn't work like that. Code: $dsn = 'mysql://username:password@localhost/table';
[eluser]dave80[/eluser]
Also not sure what purpose the third parameter serves in $this->load->database(). Originaly when I started off, any DSN connection I made, would not work. IT would basicaly default to the default database in config. So I tried http://ellislab.com/forums/viewthread/88058/ (last thread) and the manual connection would finaly work. However now I have removed auto load database, and it works with out the third parameter, as per documentation. |
Welcome Guest, Not a member yet? Register Sign In |