* or the dependency associated with the cached data has changed. */ public function get($key) { $key = $this->buildKey($key); $value = $this->getValue($key); if ($value === false || $this->serializer === false) { return $value; } elseif ($this->serializer === null) { $value = unserialize((string)$value); } else { $value = call_user_func($this->serializer[1], $value); } if (is_array($value) && !($value[1] instanceof Dependency && $value[1]->isChanged($this))) { return $value[0]; } return false; }
{ $key = $this->buildKey($key); $value = $this->getValue($key); if ($value === false || $this->serializer === false) { return $value; } elseif ($this->serializer === null) { $value = unserialize((string)$value); } else { $value = call_user_func($this->serializer[1], $value); } if (is_array($value) && !($value[1] instanceof Dependency && $value[1]->isChanged($this))) { return $value[0]; }
if ($method !== '') { $info = $this->db->getQueryCacheInfo($this->queryCacheDuration, $this->queryCacheDependency); if (is_array($info)) { /* @var $cache \yii\caching\CacheInterface */ $cache = $info[0]; $cacheKey = $this->getCacheKey($method, $fetchMode, ''); $result = $cache->get($cacheKey); if (is_array($result) && array_key_exists(0, $result)) { Yii::debug('Query result served from cache', 'yii\db\Command::query'); return $result[0]; } } }
* @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 int|null $fetchMode the result fetch mode. Please refer to [PHP manual](https://www.php.net/manual/en/pdostatement.setfetchmode.php)
public function all($db = null) { if ($this->emulateExecution) { return []; } $rows = $this->createCommand($db)->queryAll(); return $this->populate($rows); } /** * Converts the raw query results into the format as specified by this query.
* @param Connection|null $db the DB connection used to create the DB command. * If null, the DB connection returned by [[modelClass]] will be used. * @return array|ActiveRecord[] the query results. If the query results in nothing, an empty array will be returned. */ public function all($db = null) { return parent::all($db); } /** * {@inheritdoc} */ public function prepare($builder)
/** * @inheritdoc * @return Ceps[]|array */ public function all($db = null) { return parent::all($db); } /** * @inheritdoc * @return Ceps|array|null */
->where([ 'bairros.slug' => $bairro, 'cidades.slug' => $params[$idxCidade], 'estados.slug' => $params[$idxEstado] ]) ->orderBy('ceps.logradouro ASC') ->all(); }, $duration); } private function deviceType() { $detect = Yii::$app->mobileDetect;
* @see noCache() */ public function cache(callable $callable, $duration = null, $dependency = null) { $this->_queryCacheInfo[] = [$duration === null ? $this->queryCacheDuration : $duration, $dependency]; try { $result = call_user_func($callable, $this); array_pop($this->_queryCacheInfo); return $result; } catch (\Exception $e) { array_pop($this->_queryCacheInfo); throw $e; } catch (\Throwable $e) {
if ( $bairro == 'geral' ) { $bairro = ''; } return $db->cache(function ($db) use ($params, $idxEstado, $idxCidade, $bairro) { return Ceps::find() ->select(['ceps.cep', 'ceps.logradouro', 'ceps.slug', 'ceps.bairro_id']) ->joinWith(['bairro', 'cidade', 'cidade.estado'], true, 'INNER JOIN') ->where([ 'bairros.slug' => $bairro,
{ return $this->redirect('/'); } } elseif ( $tam == 3 ) { $ceps = $this->getCeps($db, $params, $duration, 0, 1, 2); if ( count($ceps) > 0 ) { return $this->render('bairroCeps', [ 'estadoInfo' => $estado, 'cidadeInfo' => $cidade,
$args = $this->controller->bindActionParams($this, $params); Yii::debug('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); if ($oldController !== null) { Yii::$app->controller = $oldController; } return $result; }
$params = $this->catchAll; unset($params[0]); } try { Yii::debug("Route requested: '$route'", __METHOD__); $this->requestedRoute = $route; $result = $this->runAction($route, $params); if ($result instanceof Response) { return $result; } $response = $this->getResponse(); if ($result !== null) {
{ 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();
require(__DIR__ . '/vendor/autoload.php'); require(__DIR__ . '/vendor/yiisoft/yii2/Yii.php'); $config = require(__DIR__ . '/config/web.php'); (new yii\web\Application($config))->run();
$_GET = [ 'ceps' => 'rn/natal/lagoa-azul', ]; $_SESSION = [ '__flash' => [], 'info' => [ 'referencia' => 'https://qualcep.me/rn/natal/lagoa-azul', 'dominio' => 'qualcep.me', 'amigo' => false, ], ];