简体   繁体   中英

Accessing remote server using Zend_Db_Table

My current system is using Zend Framework 1, and works very well with our local MySQL server. However, I now need to access another server for importing/exporting. I'm using a class extended from zend_db_table_abstract in order to query the necessary table.

class Model_Db_ExportData extends Zend_Db_Table_Abstract{
    protected $_name;
    protected $_schema;
}

I instantiate name and schema when I create the object

$export = new Model_Db_ExportData(array('name' => $this->exportTable, 'schema' => $this->db));

EDIT From what I can gather, zend_db_table isn't the place to define the host, since it only affects tables. However, I'm still unable to figure out where I can define a host outside of configs. EDIT

How do I specify a separate server from the one defined in my configs? Do I need to use custom configuration files for this code? The Zend_Db_Table_Abstract documentation wasn't very helpful, although it's quite large and I could have easily missed something. Any help is very much appreciated.

There are at least 2 possible ways to accomplish what you want:

  1. Zend_Db_Adapter - check the examples there to see how to create an adapter with the remote server settings;
  2. Zend_Config_Ini - create a file with the remote server settings and then call in your application.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM