->joinWith(['brandModel' => function(ActiveQuery $query)use ($brand){ $query->where(['brand_model.brand_id' => $brand->brand_id, 'brand_model.status' => true]); }]) ->andWhere(['brand_model_lang.alias' => $model]) ->one(); $brandSeries = BrandSeriesLang::find() ->joinWith(['brandSeries' => function(ActiveQuery $query)use($brandModel){ $query->where([ 'brand_series.brand_model_id' => $brandModel->brand_model_id, 'brand_series.status' => true ]); }]) ->andWhere(['alias' => $series, 'language_id' => $language->id]) ->one();
}]) ->andWhere(['brand_model_lang.alias' => $model]) ->one(); $brandSeries = BrandSeriesLang::find() ->joinWith(['brandSeries' => function(ActiveQuery $query)use($brandModel){ $query->where([ 'brand_series.brand_model_id' => $brandModel->brand_model_id, 'brand_series.status' => true ]); }]) ->andWhere(['alias' => $series, 'language_id' => $language->id]) ->one();
} $fullName = $prefix === '' ? $name : "$prefix.$name"; if (!isset($relations[$fullName])) { $relations[$fullName] = $relation = $primaryModel->getRelation($name); if ($callback !== null) { call_user_func($callback, $relation); } if (!empty($relation->joinWith)) { $relation->buildJoinWith(); } $this->joinWithRelation($parent, $relation, $this->getJoinType($joinType, $fullName)); }
/* @var $modelClass ActiveRecordInterface */ $modelClass = $this->modelClass; $model = $modelClass::instance(); foreach ($this->joinWith as $config) { list($with, $eagerLoading, $joinType) = $config; $this->joinWithRelations($model, $with, $joinType); if (is_array($eagerLoading)) { foreach ($with as $name => $callback) { if (is_int($name)) { if (!in_array($callback, $eagerLoading, true)) { unset($with[$name]);
{ // NOTE: because the same ActiveQuery may be used to build different SQL statements // (e.g. by ActiveDataProvider, one for count query, the other for row data query, // it is important to make sure the same ActiveQuery can be used to build SQL statements // multiple times. if (!empty($this->joinWith)) { $this->buildJoinWith(); $this->joinWith = null; // clean it up to avoid issue https://github.com/yiisoft/yii2/issues/2687 } if (empty($this->from)) { $this->from = [$this->getPrimaryTableName()]; }
* @return array the generated SQL statement (the first array element) and the corresponding * parameters to be bound to the SQL statement (the second array element). The parameters returned * include those provided in `$params`. */ public function build($query, $params = []) { $query = $query->prepare($this); $params = empty($params) ? $query->params : array_merge($params, $query->params); $clauses = [ $this->buildSelect($query->select, $params, $query->distinct, $query->selectOption), $this->buildFrom($query->from, $params),
$modelClass = $this->modelClass; if ($db === null) { $db = $modelClass::getDb(); } if ($this->sql === null) { list($sql, $params) = $db->getQueryBuilder()->build($this); } else { $sql = $this->sql; $params = $this->params; } $command = $db->createCommand($sql, $params);
public function one($db = null) { if ($this->emulateExecution) { return false; } return $this->createCommand($db)->queryOne(); } /** * Returns the query result as a scalar value. * The value returned will be the first column in the first row of the query results. * @param Connection $db the database connection used to generate the SQL statement.
* @return ActiveRecord|array|null a single row of query result. Depending on the setting of [[asArray]], * the query result may be either an array or an ActiveRecord object. `null` will be returned * if the query results in nothing. */ public function one($db = null) { $row = parent::one($db); if ($row !== false) { $models = $this->populate([$row]); return reset($models) ?: null; } return null;
'brand_series.brand_model_id' => $brandModel->brand_model_id, 'brand_series.status' => true ]); }]) ->andWhere(['alias' => $series, 'language_id' => $language->id]) ->one(); if(!isset($brandSeries)) throw new NotFoundHttpException(); $brandModel1 = BrandModelLang::find() ->where(['brand_model_id' => $brandModel->brand_model_id,
$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__ . '/../../common/config/main.php', require __DIR__ . '/../../common/config/main-local.php', require __DIR__ . '/../config/main.php', require __DIR__ . '/../config/main-local.php' ); (new yii\web\Application($config))->run();
$_GET = [ 'model' => 'bmw-xx2', 'series' => 'bmw-5-series-f10', 'filter' => 'turbina-2', 'brand' => 'bmw', ]; $_SESSION = [ '__flash' => [], ];