Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/250.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 到两个数据库的magento连接_Php_Magento - Fatal编程技术网

Php 到两个数据库的magento连接

Php 到两个数据库的magento连接,php,magento,Php,Magento,我在magento有个问题。我想用magento连接两个数据库。一个数据库将是主数据库,另一个用于存储。我不知道该怎么做。此时我的连接在app/etc/local.xml文件中……我的local.xml如下 请帮忙 假的 [mysql4]]> 1. 也许有一个比我所实现的更优雅的解决方案,但我的方法是有效的。我这样做是为了一个osCommerce导入/导出模块 /httpdocs/app/etc/config.xml <!-- osCommerce db/read/wri

我在magento有个问题。我想用magento连接两个数据库。一个数据库将是主数据库,另一个用于存储。我不知道该怎么做。此时我的连接在app/etc/local.xml文件中……我的local.xml如下 请帮忙 假的 [mysql4]]> 1.

也许有一个比我所实现的更优雅的解决方案,但我的方法是有效的。我这样做是为了一个osCommerce导入/导出模块


/httpdocs/app/etc/config.xml

        <!-- osCommerce db/read/write -->
        <oscommercedb>
            <connection>
                <host>localhost</host>
                <username>root</username>
                <password>pass</password>
                <dbname>oscommerce_database_name</dbname>
                <model>mysql4</model>
                <initstatements>SET NAMES utf8</initstatements>
                <type>pdo_mysql</type>
                <active>1</active>
            </connection>
        </oscommercedb>
        <oscommercedb_write>
            <connection>
                <use>oscommercedb</use>
            </connection>
        </oscommercedb_write>
        <oscommercedb_read>
            <connection>
                <use>oscommercedb</use>
            </connection>
        </oscommercedb_read>
        <!-- end osCommerce db -->


如果遇到特定问题,请告诉我。

尝试此链接非常感谢您的帮助。我可以用您的代码轻松地完成此操作。
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')->getConnection('oscommercedb');

    $stmt = $read->select();

    $stmt->from(array('c' => 'customers'))
         ->join(array('a' => 'address_book'), 'a.address_book_id = c.customers_default_address_id')
         ->joinLeft('zones', 'zones.zone_id = a.entry_zone_id')
         ->join('countries','a.entry_country_id = countries.countries_id', array('countries_iso_code_2'));

    return $read->fetchAll($stmt);
}