Exemple #1
0
 /**
  * Copies table data from development to test
  * 
  * Copies table data from a table in the development databse to one in the test database
  * Connects to the dev database, fetches all records 
  * then connects to the test db and does th inserts
  * 
  * @param	string	$table	The name of the table to copy
  * @access 	public
  */
 public function loadTable($table)
 {
     // get the development database
     Zend_ConfigSettings::setUpConfigEnv('development');
     Zend_ConfigSettings::setUpDBAdapter();
     $devDb = Zend_Registry::get('db');
     // get the test database
     Zend_ConfigSettings::setUpConfigEnv('local');
     Zend_ConfigSettings::setUpDBAdapter();
     $testDb = Zend_Registry::get('db');
     $stmt = $devDb->query("SELECT * FROM {$table}");
     $tableData = $stmt->fetchAll();
     if ($tableData) {
         $testDb->query("TRUNCATE TABLE {$table}");
         foreach ($tableData as $tableRow) {
             $data = array();
             foreach ($tableRow as $key => $value) {
                 $data[$key] = $value;
             }
             $testDb->insert($table, $data);
         }
     }
 }