MySQLi could be re-using the same database connection internally which
when you swap databases causes an issue. This was fixed in the MySQL
driver with the new link flag being set on connect but MySQLi doesn't
have that. Not sure if that feature is still there but it might be
worth investigating. Also check if you have persistent connections set
somewhere in the PHP configuration.
Try swapping the driver to MySQL and see if it makes a difference.
Additionally try swapping the core to MySQL and using MySQLi and see
if that changes anything.
It may also pay to double check that for some reason you're not
getting a same copy of the database back but I don't think that would
be the case. Doesn't harm to check. Perhaps var_dump it and see what
it says it's doing and compare that to the normal one.
The only other thing I can think of it is that your server's php.ini
file has some database settings in it that are overriding the
connection. I'm a little hazy on how that all interacts with the
settings but that's also another possibility as an extreme edge case.
Also, the code sample you provided is incomplete. In the fragment you
return the query but don't execute it. Are you sure you're not
providing the query to the original database connection anyway? This
works fine for me:
<?php
<?php
$option = array(); //prevent problems
$option['driver'] = 'mysqli'; // Database driver name
$option['host'] = '127.0.0.1'; // Database host name
$option['user'] = 'myuser'; // User for database authentication
$option['password'] = 'xyz'; // Password for database authentication
$option['database'] = 'DIFFERENT_DATABASE'; // Database name
$option['prefix'] = ''; // Database prefix (may be empty)
$db = & JDatabase::getInstance( $option );
$query = $db->getQuery(true);
$query->select('*');
$query->from('articles');
$db->setQuery($query);
var_dump($db->loadObjectList());
?>
Cheers,
Sam Moffatt
http://pasamio.id.au
> --
> You received this message because you are subscribed to the Google Groups "Joomla! General Development" group.
> To post to this group, send an email to
joomla-de...@googlegroups.com.
> To unsubscribe from this group, send email to
joomla-dev-gene...@googlegroups.com.
> For more options, visit this group at
http://groups.google.com/group/joomla-dev-general?hl=en-GB.
>