Connecting to second db issue |
[eluser]Bramme[/eluser]
Hey all. I need to connect to a second db (the phpbb db) to fetch a list of recent topics. I use this code: Code: $dsn = 'mysql://user:pass@localhost/phpbb3';
[eluser]Hannes Nevalainen[/eluser]
I'm not sure you can access your database with a dsn,, Setup a second connection in your config/database.php =) DB connection in user guide Happy Coding =)
[eluser]Bramme[/eluser]
From that same page... Quote:Or you can submit your database values as a Data Source Name. DSNs must have this prototype:
[eluser]Hannes Nevalainen[/eluser]
Srry, My bad. Try to Code: echo '<pre>',print_r($query),'</pre>'; Post the results please, (if it doesn't help ypu)
[eluser]Bramme[/eluser]
Code: echo "query: <pre>"; Code: query: <pre></pre>
[eluser]Bramme[/eluser]
Okay, nevermind. it's clearly a bug, because when I connect using a different group in the database config file, everything works.
[eluser]Hannes Nevalainen[/eluser]
look at the top in sourece (the print_r()) echoes it's result, to ,make it return you have to provide the second parameter bool:TRUE). print_r($query,true); I forgot this (like always)
[eluser]xwero[/eluser]
My guess is if you load a connection string the AR library isn't available. If that is the problem it should be mentioned somewhere in the documentation and also a way to make the AR library available working with connection strings. You could try Code: $query = $this->db->query('SELECT phpbb3_topics.* FROM phpbb3_topics JOIN phpbb3_posts ON phpbb3_posts.topic_id = phpbb3_topics.topic_id LIMIT 4');
[eluser]Bramme[/eluser]
Okay, this is even more annoying. I can succesfully connect to the second database. Though when I do that, even if I use mysql_close(), the database library uses the second database to do all my other queries. Offcourse I end up with an sql error then because it can't find the tables.
|
Welcome Guest, Not a member yet? Register Sign In |