} /** * {@inheritdoc} * @throws InvalidArgumentException if wrong number of operands have been given. */ public static function fromArrayDefinition($operator, $operands) { if (!isset($operands[0], $operands[1])) { throw new InvalidArgumentException("Operator '$operator' requires two operands."); } $condition = new static($operands[0], $operator, $operands[1]); if (isset($operands[2])) { $condition->escapingReplacements = $operands[2]; } return $condition; }
if (isset($this->conditionClasses[$operator])) { $className = $this->conditionClasses[$operator]; } else { $className = 'yii\db\conditions\SimpleCondition'; } /** @var ConditionInterface $className */ return $className::fromArrayDefinition($operator, $condition); } // hash format: 'column1' => 'value1', 'column2' => 'value2', ... return new HashCondition($condition); }
{ if (is_array($condition)) { if (empty($condition)) { return ''; } $condition = $this->createConditionFromArray($condition); } if ($condition instanceof ExpressionInterface) { return $this->buildExpression($condition, $params); }
*/ private function buildExpressionsFrom(ExpressionInterface $condition, &$params = []) { $parts = []; foreach ($condition->getExpressions() as $condition) { if (is_array($condition)) { $condition = $this->queryBuilder->buildCondition($condition, $params); } if ($condition instanceof ExpressionInterface) { $condition = $this->queryBuilder->buildExpression($condition, $params); } if ($condition !== '') { $parts[] = $condition;
* @param ExpressionInterface|ConjunctionCondition $condition the expression to be built. * @param array $params the binding parameters. * @return string the raw SQL that will not be additionally escaped or quoted. */ public function build(ExpressionInterface $condition, array &$params = []) { $parts = $this->buildExpressionsFrom($condition, $params); if (empty($parts)) { return ''; } if (count($parts) === 1) {
* @throws InvalidArgumentException when $expression building is not supported by this QueryBuilder. */ public function buildExpression(ExpressionInterface $expression, &$params = []) { $builder = $this->getExpressionBuilder($expression); return $builder->build($expression, $params); } /** * Gets object of [[ExpressionBuilderInterface]] that is suitable for $expression. * Uses [[expressionBuilders]] array to find a suitable builder class. *
} $condition = $this->createConditionFromArray($condition); } if ($condition instanceof ExpressionInterface) { return $this->buildExpression($condition, $params); } return (string) $condition; } /**
* @param string|array $condition * @param array $params the binding parameters to be populated * @return string the WHERE clause built from [[Query::$where]]. */ public function buildWhere($condition, &$params) { $where = $this->buildCondition($condition, $params); return $where === '' ? '' : 'WHERE ' . $where; } /** * @param array $columns
$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), $this->buildJoin($query->join, $params), $this->buildWhere($query->where, $params), $this->buildGroupBy($query->groupBy), $this->buildHaving($query->having, $params), ]; $sql = implode($this->separator, array_filter($clauses)); $sql = $this->buildOrderByAndLimit($sql, $query->orderBy, $query->limit, $query->offset);
$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. * This method is internally used to convert the data fetched from database
* @param Connection $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)
foreach ($model_o as $item) { $options[$item['xoption_id']] = $item; } // پست های مرتبط $related_posts = Blog::find()->where(['like', 'title', $attr[Yii::$app->params['brand']]['product_attribute_value']]) ->orWhere(['like', 'title', $attr[Yii::$app->params['model']]['product_attribute_value']])->limit(3)->all(); if (!$related_posts) { $related_posts = Blog::find()->limit(3)->orderBy('id desc')->all(); } // خودروهای مشابه $ids = ProductAttribute::find()->select('product_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();
//defined('_MPDF_SYSTEM_TTFONTS_CONFIG') or define('_MPDF_SYSTEM_TTFONTS_CONFIG', __DIR__ . '/saipa_script/config/mpdf/config.php'); require(__DIR__ . '/../demo_script/vendor/autoload.php'); require(__DIR__ . '/../demo_script/vendor/yiisoft/yii2/Yii.php'); $config = require(__DIR__ . '/../demo_script/config/web.php'); (new yii\web\Application($config))->run();
$_GET = [ 'product_id' => '3128', ];