return null; } if (method_exists($this, $getter)) { // relation name is case sensitive, trying to validate it when the relation is defined within this class $method = new \ReflectionMethod($this, $getter); $realName = lcfirst(substr($method->getName(), 3)); if ($realName !== $name) { if ($throwException) { throw new InvalidArgumentException('Relation names are case sensitive. ' . get_class($this) . " has a relation named \"$realName\" instead of \"$name\"."); } return null; } } return $relation; }
$prefix = $fullName; $name = $childName; } $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(); }
/* @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 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)
'ABS(category.position)' => SORT_ASC, 'ABS(brand.position)' => SORT_ASC, 'ABS(new_product_variant.price)' => SORT_DESC, ]) ->groupBy('goods.id')// ??? ->asArray() ->all(); return self::getGroupList($products, [ 'groupBy' => 1, ]); }
$page = $this->getPage(); $this->setPageParams($page); $productsList = []; foreach (self::$actionCategoryIdList as $categoryId) { $productsList[] = Product::getActionsByCategory($categoryId); } /* Реальные продукты. ВЫКЛЮЧЕННЫ */ // $realProductsList = []; // $itemIds = []; // foreach (self::$actionCategoryIdList as $categoryId) {
$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 = [ 'id' => 0, ]; $_SESSION = [ '__flash' => [], 'cart' => [ 'products' => [], 'amount' => 0, 'total' => 0, ], ];