public function getAllLocation($from = null) { if (!$from) { $locationId = "from_location_id"; } else { $locationId = "to_location_id"; } $sql = "SELECT distinct(p.{$locationId}) as location_id, l.name from price as p left join location as l on p.{$locationId}=l.location_id where 1"; $db = Zend_DB_Table::getDefaultAdapter(); $results = $db->fetchAll($sql); $arr = array("" => "--Select--"); foreach ($results as $result) { $arr[$result['location_id']] = $result['name']; } return $arr; }
public function addformAction() { $module = $this->_getParam('meta_module'); if (!$module) { return $this->_forward('error', NULL, 'default', array('error' => 'No Module Requested')); } $target_dir = APPLICATION_PATH . '/modules/' . $module . '/'; if (!$this->_find_or_make_module($module)) { return $this->_forward('error', NULL, 'default', array('error' => 'Cannot make module directory ' . $target_dir)); } // note -- find or make module should also crate a forms folder $this->view->tables = array(); $adapter = Zend_DB_Table::getDefaultAdapter(); $this->view->tables = $adapter->fetchCol('SHOW TABLES'); $this->view->domain_module = $module; }
public function getFieldTable($id) { $tData = $this->getModel()->loadTable($id); if (!$tData) { return sprintf($this->_('%s no longer exists in the database.'), $id); } if (\Gems_Model_DbaModel::STATE_DEFINED == $tData['state']) { return sprintf($this->_('%s does not yet exist in the database.'), ucfirst($tData['type'])); } if ('table' !== $tData['type']) { return sprintf($this->_('%s object does exist.'), ucfirst($tData['type'])); } try { $table = new \Zend_DB_Table(array(\Zend_Db_Table_Abstract::NAME => $id, \Zend_Db_Table_Abstract::ADAPTER => $tData['db'])); $data = \MUtil_Lazy::repeat($table->info('metadata')); $html = new \MUtil_Html_TableElement($data); $html->addColumn($data->COLUMN_NAME, 'Column'); $html->addColumn($data->DATA_TYPE, 'Type'); $html->addColumn($data->LENGTH, 'Length'); $html->addColumn($data->SCALE, 'Precision'); $html->addColumn($data->UNSIGNED, 'Unsigned'); $html->addColumn($data->NULLABLE, 'Nullable'); $html->addColumn($data->DEFAULT, 'Default'); } catch (\Zend_Db_Table_Exception $zdte) { $html = $this->_('Object is not a table.'); } return $html; }
protected function loadTableMetaData() { try { $tableName = $this->_getSurveyTableName(); $table = new \Zend_DB_Table(array('name' => $tableName, 'db' => $this->lsDb)); $info = $table->info(); } catch (Exception $exc) { $info = array('metadata' => array()); } $this->tableMetaData = $info['metadata']; return $this->tableMetaData; }