return; } if (!empty($this->masters)) { $db = $this->openFromPool($this->masters, $this->masterConfig); if ($db !== null) { $this->pdo = $db->pdo; return; } else { throw new InvalidConfigException('None of the master DB servers is available.'); } } if (empty($this->dsn)) { throw new InvalidConfigException('Connection::dsn cannot be empty.'); } $token = 'Opening DB connection: ' . $this->dsn; try { Yii::info($token, __METHOD__);
* Returns the PDO instance for the currently active master connection. * This method will open the master DB connection and then return [[pdo]]. * @return PDO the PDO instance for the currently active master connection. */ public function getMasterPdo() { $this->open(); return $this->pdo; } /** * Returns the currently active slave connection. * If this method is called the first time, it will try to open a slave connection when [[enableSlaves]] is true.
* is available and `$fallbackToMaster` is false. */ public function getSlavePdo($fallbackToMaster = true) { $db = $this->getSlave(false); if ($db === null) { return $fallbackToMaster ? $this->getMasterPdo() : null; } else { return $db->pdo; } } /**
if ($this->db->getTransaction()) { // master is in a transaction. use the same connection. $forRead = false; } if ($forRead || $forRead === null && $this->db->getSchema()->isReadQuery($sql)) { $pdo = $this->db->getSlavePdo(); } else { $pdo = $this->db->getMasterPdo(); } try { $this->pdoStatement = $pdo->prepare($sql);
Yii::trace('Query result served from cache', 'yii\db\Command::query'); return $result[0]; } } } $this->prepare(true); $token = $rawSql; try { Yii::beginProfile($token, 'yii\db\Command::query'); $this->pdoStatement->execute();
* @return array all rows of the query result. Each array element is an array representing a row of data. * An empty array is returned if the query results in nothing. * @throws Exception execution failed */ public function queryAll($fetchMode = null) { return $this->queryInternal('fetchAll', $fetchMode); } /** * Executes the SQL statement and returns the first row of the result. * This method is best used when only the first row of result is needed for a query. * @param integer $fetchMode the result fetch mode. Please refer to [PHP manual](http://www.php.net/manual/en/function.PDOStatement-setFetchMode.php)
$sql = $subSql." LIMIT $start , $rows"; if($order_by_order){//排序字段优先 $sql = "SELECT * FROM ($subSql) AS t ORDER BY t.r DESC LIMIT $start , $rows"; } $list = \Yii::$app->db->createCommand($sql)->queryAll(); if($list){//URL foreach ($list as &$v){ $urltitle = $v['title']; $urltitle = strtolower($urltitle); $urltitle = preg_replace('/[^a-z0-9\s]/','',$urltitle);
$this->view->params['keyword'] = "liberators review,liberators events,wargames,ww2 games,mutantbox"; $this->view->params['description'] = "Read all latest news about liberators from mutantbox.com. All liberators review and liberators events, gaming industry news and more.More details click here! "; $this->view->params['micend'] = isset($_GET['micend'])?$_GET['micend']:0; $fid = \Yii::$app->request->get('fid',null); $article = new News_Multi_Language; $articleList = $article->getArticleList($fid,10,false,intval(\Yii::$app->request->get('page',1)-1)*10, LANG_SET, 4); $count = $article->getCount($fid,false, LANG_SET, 4); if($count['0']['num']<1){ $articleList = $article->getArticleList($fid,10,false,intval(\Yii::$app->request->get('page',1)-1)*10,'en-us', 4); $count = $article->getCount($fid,false,'en-us', 4); } $pages = new Pagination(['totalCount' =>$count[0]['num'], 'pageSize' => 10,'route'=>'/news']);
$args = $this->controller->bindActionParams($this, $params); Yii::trace('Running action: ' . get_class($this->controller) . '::' . $this->actionMethod . '()', __METHOD__); if (Yii::$app->requestedParams === null) { Yii::$app->requestedParams = $args; } return call_user_func_array([$this->controller, $this->actionMethod], $args); } }
} $result = null; if ($runAction && $this->beforeAction($action)) { // run the action $result = $action->runWithParams($params); $result = $this->afterAction($action, $result); // call afterAction on modules foreach ($modules as $module) { /* @var $module Module */
$parts = $this->createController($route); if (is_array($parts)) { /* @var $controller Controller */ list($controller, $actionID) = $parts; $oldController = Yii::$app->controller; Yii::$app->controller = $controller; $result = $controller->runAction($actionID, $params); Yii::$app->controller = $oldController; return $result; } else { $id = $this->getUniqueId(); throw new InvalidRouteException('Unable to resolve the request "' . ($id === '' ? $route : $id . '/' . $route) . '".');
$params = $this->catchAll; unset($params[0]); } try { Yii::trace("Route requested: '$route'", __METHOD__); $this->requestedRoute = $route; $result = $this->runAction($route, $params); if ($result instanceof Response) { return $result; } else { $response = $this->getResponse(); if ($result !== null) { $response->data = $result;
try { $this->state = self::STATE_BEFORE_REQUEST; $this->trigger(self::EVENT_BEFORE_REQUEST); $this->state = self::STATE_HANDLING_REQUEST; $response = $this->handleRequest($this->getRequest()); $this->state = self::STATE_AFTER_REQUEST; $this->trigger(self::EVENT_AFTER_REQUEST); $this->state = self::STATE_SENDING_RESPONSE; $response->send();
$config = require(__DIR__ . '/../config/web.php'); //check LANGUAGE require(__DIR__ . '/../filters/LangFilter.php'); //阿里大鱼 require(__DIR__ . '/../vendor/alidayu/vendor/autoload.php'); (new yii\web\Application($config))->run();
$_GET = [ 'micend' => '0', 'page' => '7', 'per-page' => '10', ];