Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>There may be a more elegant solution that what I've implemented, but my method works. I did this for an osCommerce import/export module.</p> <hr> <p>/httpdocs/app/etc/config.xml</p> <pre><code> &lt;!-- osCommerce db/read/write --&gt; &lt;oscommercedb&gt; &lt;connection&gt; &lt;host&gt;localhost&lt;/host&gt; &lt;username&gt;root&lt;/username&gt; &lt;password&gt;pass&lt;/password&gt; &lt;dbname&gt;oscommerce_database_name&lt;/dbname&gt; &lt;model&gt;mysql4&lt;/model&gt; &lt;initstatements&gt;SET NAMES utf8&lt;/initstatements&gt; &lt;type&gt;pdo_mysql&lt;/type&gt; &lt;active&gt;1&lt;/active&gt; &lt;/connection&gt; &lt;/oscommercedb&gt; &lt;oscommercedb_write&gt; &lt;connection&gt; &lt;use&gt;oscommercedb&lt;/use&gt; &lt;/connection&gt; &lt;/oscommercedb_write&gt; &lt;oscommercedb_read&gt; &lt;connection&gt; &lt;use&gt;oscommercedb&lt;/use&gt; &lt;/connection&gt; &lt;/oscommercedb_read&gt; &lt;!-- end osCommerce db --&gt; </code></pre> <hr> <p>This gives you the ability to call <code>oscommercedb</code> within your models. The above code goes within the <code>&lt;resources&gt;</code> block.</p> <p>Let's take a look at a model now.</p> <hr> <p>/httpdocs/app/code/local/Company/Extension/Model/OsCustomers.php</p> <pre><code>class Company_Extension_Model_OsCustomers extends Mage_Core_Model_Abstract { protected $_name = 'customers'; // name of the table /** * Returns rowset of tables for customers * * @return Zend_Db_Table_Rowset */ public function getAllOscommerceCustomers() { $read = Mage::getSingleton('core/resource')-&gt;getConnection('oscommercedb'); $stmt = $read-&gt;select(); $stmt-&gt;from(array('c' =&gt; 'customers')) -&gt;join(array('a' =&gt; 'address_book'), 'a.address_book_id = c.customers_default_address_id') -&gt;joinLeft('zones', 'zones.zone_id = a.entry_zone_id') -&gt;join('countries','a.entry_country_id = countries.countries_id', array('countries_iso_code_2')); return $read-&gt;fetchAll($stmt); } </code></pre> <hr> <p>If you run into a specific problem let me know.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload