私はMagentoで問題があります。私はmagento.oneデータベースと2つのデータベースを接続したい、メインデータベースともう1つは店舗になります。私は を助けてください偽 を次の私のlocal.xmlがある.....私の接続は、ファイルアプリの/ etc/local.xmlであるit.Byこの時間を行う方法を知りません [mysql4]]> 2つのデータベースへのmagento接続
3
A
答えて
2
私が実装しているより洗練された解決策があるかもしれませんが、私の方法は機能します。私は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 -->
これは、あなたのモデル内oscommercedb
を呼び出す機能を提供します。上記のコードは<resources>
ブロック内にあります。
今すぐモデルを見てみましょう。
/httpdocs/app/code/local/Company/Extension/Model/OsCustomers.php
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);
}
あなたは、特定の問題に遭遇した場合は私に知らせてください。
+0
助けてくれてありがとうございます。私はあなたのコードで非常に簡単にそれを行うことができました。 –
+0
ありがとうございます。良い仕事を続ける –
関連する問題
- 1. Magento 2別々の読み取り/書き込みデータベース接続
- 2. 2つのデータベース接続:php + mysql
- 3. 2つのデータベースに接続する
- 4. 2つのデータベースを接続する
- 5. 2つのデータベースをlaravelに接続
- 6. Firebase/Swift 2つのデータベース接続
- 7. データベースへのJavaの接続
- 8. Tableau - データベースへのAWS接続
- 9. mysqlへのC++データベース接続
- 10. SQLデータベースへの接続#
- 11. SQLデータベースへの接続
- 12. SQLite:リソースファイルへのデータベース接続?
- 13. データベースへのMySql PDO接続
- 14. postgresqlデータベースへのJava接続
- 15. HeidiSQLは、MySQLサーバへの接続 - データベースへの接続に初期
- 16. Odoo - Magento 2接続の問題
- 17. magento 2分割データベースと新しい接続を使用
- 18. Mi Band 2への接続
- 19. 2つのrdsインスタンスから1つのec2インスタンスへの接続
- 20. CodeIgniter 2 +複数のデータベース接続を持つDoctrine 2
- 21. データベースへのアプレットの接続JNLPエラー
- 22. C#形式のOracleデータベースへの接続
- 23. C#でのデータベースへの接続:ArgumentException
- 24. アクティブレコードに複数のデータベースへの接続
- 25. Sourceforge.netへの接続NetbeansのMySQLデータベース
- 26. マルチティアサーバ上のデータベースへのセキュアな接続
- 27. Rubyでのリモートマシンへのデータベース接続
- 28. データベースへのAndroidアプリケーションの接続
- 29. ホスト上のMySqlデータベースへの接続
- 30. RJDBC、OracleデータベースへのJava接続のクラッシュ
http://blog.decryptweb.com/connect-database-magento/このリンクを試す – sulabh