Context: Joomla 3.8.5 MySQL Joomla database = berrien_dev External database = BMP PHP 5.6.33
I am attempting to access in a component I am writing an external database that sits in the same MySQL server as my Joomla site. After installing and running the component on the site side, I receive this message twice "Table 'berrien_dev.Estim' doesn't exist". As you can see, it is trying to find my table in the wrong database and I am stumped as to why.
Here is my model:
protected function getListQuery()
{
// Initialize variables and connect to remote MS SQL server
$option = array(); //prevent problems
$option['driver'] = 'mysqli'; // Database driver name
$option['host'] = 'localhost'; // Database host name
$option['user'] = 'mysqluser'; // User for database authentication
$option['password'] = 'somepassword'; // Password for database authentication
$option['database'] = 'BMP'; // Database name
$option['prefix'] = ''; // Database prefix (may be empty)
// Connect to external database
$E2db = JDatabaseDriver::getInstance( $option );
$query = $E2db->getQuery(true);
// Create the base select statement.
$query->select('a.PartNo as PartNo, a.Descrip as Descrip, a.CustCode as CustCode,
a.EntDate as EntDate, a.EntBy as EntBy, a.ModDate as ModDate, a.ModBy as Modby')
->from($E2db->quoteName('Estim', 'a'));
return $query;
}
Thanks for your help!
var_dump($E2db);
right after$E2db = JDatabaseDriver::getInstance( $option );
? – Ben Harold Mar 16 '18 at 0:30