/** * 选择合适的游戏类型 * * @param Zend_Db_Select $select * @param boolean $group * @return Zend_Db_Select */ protected function _selectGameTypes(Zend_Db_Select $select, $group = false) { $tableName = $this->_tableDAO->info('name'); $column = (strstr($tableName, '_', true) ?: $tableName) . '_gametype'; if (is_array(self::$_allowedGameTypes) && is_array($this->_gameTypes)) { $gameTypes = array_intersect($this->_gameTypes, self::$_allowedGameTypes); } else { if (is_array(self::$_allowedGameTypes)) { $gameTypes = self::$_allowedGameTypes; } else { if (is_array($this->_gameTypes)) { $gameTypes = $this->_gameTypes; } } } if (isset($gameTypes) && !empty($gameTypes)) { count($gameTypes) === 1 ? $select->where("{$column} = ?", $gameTypes) : $select->where("{$column} IN (?)", $gameTypes); } if (true === $group) { if (!in_array(ZtChart_Model_Assemble::GAMETYPE, $this->_merge)) { array_unshift($this->_merge, ZtChart_Model_Assemble::GAMETYPE); } $select->columns("{$column} AS " . ZtChart_Model_Assemble::GAMETYPE)->group(ZtChart_Model_Assemble::GAMETYPE); } return $select; }
/** * 错误显示 */ public function errorAction() { $errors = $this->_getParam('error_handler'); if (!$errors || !$errors instanceof ArrayObject) { $this->view->message = 'You have reached the error page'; return; } switch ($errors->type) { case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE: case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER: case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION: // 404 error -- controller or action not found $this->getResponse()->setHttpResponseCode(404); $priority = Zend_Log::NOTICE; $this->view->message = 'Page not found'; break; default: // application error $this->getResponse()->setHttpResponseCode(500); $priority = Zend_Log::CRIT; $this->view->message = 'Application error'; break; } // Log exception, if logger available if (null != ($log = $this->getLog())) { $log->log($this->view->message, $priority, $errors->exception); $log->log('Request Parameters', $priority, $errors->request->getParams()); } // Db exception, if db profiler is set if ($errors->exception instanceof Zend_Db_Exception) { foreach (ZtChart_Model_Db_Table_Abstract::getInstanceTableAdapters() as $adapter) { $profiler = $adapter->getProfiler(); for ($queryId = 0; $queryId < $profiler->getTotalNumQueries(); $queryId++) { if (!$profiler->getQueryProfile($queryId)->hasEnded()) { $this->view->profile = $profiler->getQueryProfile($queryId); break; } } } } // conditionally display exceptions if ($this->getInvokeArg('displayExceptions') == true) { $this->view->exception = $errors->exception; } $this->view->request = $errors->request; }
/** * * @param integer $gameType * @param string $datetime * @param mixed $config * @throws ZtChart_Model_Db_Table_Exception */ public function __construct($gameType, $datetime = null, $config = array()) { parent::__construct($config); if (self::isSingleAdapter($gameType)) { $this->_setAdapter(self::$_infoServerAdapters[$gameType][0]); } $this->setTablename($datetime); }
/** * 设置所有注册的表的默认适配器 * * @static * @param array $adapters * @return void */ public static function setDefaultTableAdapters($adapters) { self::$_defaultTableDb = $adapters; }