私は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. 2つのデータベースに接続する
- 2. 2つのデータベース接続:php + mysql
- 3. データベースへのJavaの接続
- 4. SQLデータベースへの接続#
- 5. mysqlへのC++データベース接続
- 6. データベースへのMySql PDO接続
- 7. SQLite:リソースファイルへのデータベース接続?
- 8. SQLデータベースへの接続
- 9. HeidiSQLは、MySQLサーバへの接続 - データベースへの接続に初期
- 10. CodeIgniter 2 +複数のデータベース接続を持つDoctrine 2
- 11. CodeIgniter 2 my_router.phpデータベース接続
- 12. Zend Framework 2 - データベース接続
- 13. Linux上のOracleデータベースへのpyodbc接続
- 14. Sourceforge.netへの接続NetbeansのMySQLデータベース
- 15. アクティブレコードに複数のデータベースへの接続
- 16. C#形式のOracleデータベースへの接続
- 17. Rubyでのリモートマシンへのデータベース接続
- 18. データベースへのAndroidアプリケーションの接続
- 19. C#でのデータベースへの接続:ArgumentException
- 20. データベースへのアプレットの接続JNLPエラー
- 21. 2つのクライアントソケットを接続
- 22. H2データベースへのPHP ODBC接続
- 23. Excel/VBA Oracleデータベースへの接続
- 24. Xamarin.AndroidアプリケーションSQLデータベースへの接続
- 25. SQL Serverデータベースへの最大接続数
- 26. Javaを使ったデータベースへの接続
- 27. データベースへの接続を確立する
- 28. 異なるデータベース・バージョンへの接続
- 29. フレックスによるデータベースへの接続
- 30. PHP PDO Advantageデータベースへの接続SQL Server
http://blog.decryptweb.com/connect-database-magento/このリンクを試す – sulabh