0

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.

TheMonarch
  • 577
  • 1
  • 5
  • 19

1 Answers1

1

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.
Rolando Isidoro
  • 4,983
  • 2
  • 31
  • 43
  • As a follow-up, can I use zend_db_adaptor in the same way I can use zend_db_table? I see in the docs that I can pass queries to it in the form of regular sql, and that I can use fetchAll etc. with it. Does it have the same flexibility with where(), join() and so on? – TheMonarch Apr 18 '13 at 19:53
  • 1
    You can still use Zend_Db_Table, just create your Zend_Db_Adaptor 1st and then call **Zend_Db_Table::setDefaultAdapter($dbAdapter);**. – Rolando Isidoro Apr 18 '13 at 19:57
  • I'm only sorry I can't upvote you ten or twelve more times. Thank you. – TheMonarch Apr 18 '13 at 20:08