Hi so I am trying to add in a connection to another database in Magento so I can query it, I have done the following:
Made a module and this is my config.xml:
<?xml version="1.0"?>
<config>
<global>
<resources>
<externaldb_write>
<connection>
<use>externaldb_database</use>
</connection>
</externaldb_write>
<externaldb_read>
<connection>
<use>externaldb_database</use>
</connection>
</externaldb_read>
<externaldb_setup>
<connection>
<use>core_setup</use>
</connection>
</externaldb_setup>
<externaldb_database>
<connection>
<host><![CDATA[IPADDRESS]]></host>
<username><![CDATA[USERNAME]]></username>
<password><![CDATA[PASSWORD]]></password>
<dbname><![CDATA[DATABASE]]></dbname>
<model>mysql4</model>
<type>pdo_mysql</type>
<active>1</active>
</connection>
</externaldb_database>
</resources>
</global>
</config>
And this is my code frontend:
<?php
$resource = Mage::getSingleton('core/resource');
$conn = $resource->getConnection('externaldb_read');
$results = $conn->query('SELECT * FROM tablename');
print_r($results);
?>
And I get the following error:
a:5:{i:0;s:125:"SQLSTATE[42S02]: Base table or view not found: 1146 Table 'admin_magento_t.tablename' doesn't exist, query was: SELECT * FROM tablename";i:1;s:3026:"#0 /SERVERPATH/lib/Varien/Db/Statement/Pdo/Mysql.php(110): Zend_Db_Statement_Pdo->_execute(Array)
I am confused why it says table "admin_magento_t.tablename" doesnt exist when I am only looking for "tablename"? I have tried this connection manually in PHP and it connects to the database fine
Can someone advise me on this?
Thanks!