in /var/www/www-root/data/www/077.ru/vendor/yiisoft/yii2/db/Connection.php at line 630
$token = 'Opening DB connection: ' . $this->dsn; try { Yii::info($token, __METHOD__); Yii::beginProfile($token, __METHOD__); $this->pdo = $this->createPdoInstance(); $this->initConnection(); Yii::endProfile($token, __METHOD__); } catch (\PDOException $e) { Yii::endProfile($token, __METHOD__); throw new Exception($e->getMessage(), $e->errorInfo, (int) $e->getCode(), $e); } } /** * Closes the currently active DB connection. * It does nothing if the connection is already closed. */ public function close() {
* 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 for 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(); } if (!empty($this->floatParams)) { $sql = $this->parseFloatParams($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 int $fetchMode the result fetch mode. Please refer to [PHP manual](http://www.php.net/manual/en/function.PDOStatement-setFetchMode.php)
* @return array all index names in the Sphinx. */ protected function findIndexes() { $sql = 'SHOW TABLES'; return $this->db->createCommand($sql)->queryAll(); } /** * @return QueryBuilder the query builder for this connection. */ public function getQueryBuilder()
* Initializes information about name and type of all index in the Sphinx. */ protected function initIndexesInfo() { $this->_indexNames = []; $this->_indexTypes = []; $indexes = $this->findIndexes(); foreach ($indexes as $index) { $indexName = $index['Index']; $this->_indexNames[] = $indexName; $this->_indexTypes[$indexName] = $index['Type']; } }
* index types fetched previously (if available) will be returned. * @return array all index types in the Sphinx in format: index name => index type. */ public function getIndexTypes($refresh = false) { if (!isset($this->_indexTypes) || $refresh) { $this->initIndexesInfo(); } return $this->_indexTypes; } /**
/** * Resolves the index name. * @param IndexSchema $index the index metadata object */ protected function resolveIndexType($index) { $indexTypes = $this->getIndexTypes(); $index->type = array_key_exists($index->name, $indexTypes) ? $indexTypes[$index->name] : 'unknown'; $index->isRuntime = ($index->type == 'rt'); } /** * Obtains the metadata for the named index.
* @return IndexSchema|null driver dependent index metadata. `null` - if the index does not exist. */ protected function loadIndexSchema($name) { $index = new IndexSchema(); $this->resolveIndexNames($index, $name); $this->resolveIndexType($index); if ($this->findColumns($index)) { return $index; } return null; }
} return $this->_indexes[$name] = $index; } } return $this->_indexes[$name] = $this->loadIndexSchema($realName); } /** * Returns the cache key for the specified index name. * @param string $name the index name * @return mixed the cache key
* @param string $name index name. * @param bool $refresh whether to reload the table schema even if it is found in the cache. * @return IndexSchema index schema information. Null if the named index does not exist. */ public function getIndexSchema($name, $refresh = false) { return $this->getSchema()->getIndexSchema($name, $refresh); } /** * Quotes a index name for use in a query. * If the index name contains schema prefix, the prefix will also be properly quoted. * If the index name is already quoted or contains special characters including '(', '[[' and '{{',
*/ private function getIndexSchemas($indexes) { $indexSchemas = []; if (!empty($indexes)) { foreach ($indexes as $indexName) { $index = $this->db->getIndexSchema($indexName); if ($index !== null) { $indexSchemas[] = $index; } } } return $indexSchemas;
} } if (empty($condition)) { return ''; } $indexSchemas = $this->getIndexSchemas($indexes); $where = $this->buildCondition($indexSchemas, $condition, $params); return $where === '' ? '' : 'WHERE ' . $where; } /**
$from = [$modelClass::indexName()]; } $clauses = [ $this->buildSelect($query->select, $params, $query->distinct, $query->selectOption), $this->buildFrom($from, $params), $this->buildWhere($from, $query->where, $params, $query->match), $this->buildGroupBy($query->groupBy, $query->groupLimit), $this->buildWithin($query->within), $this->buildHaving($query->from, $query->having, $params), $this->buildOrderBy($query->orderBy), $this->buildLimit($query->limit, $query->offset), $this->buildOption($query->options, $params),
* @return Command the created Sphinx command instance. */ public function createCommand($db = null) { $this->setConnection($db); $db = $this->getConnection(); list ($sql, $params) = $db->getQueryBuilder()->build($this); return $db->createCommand($sql, $params); } /** * @inheritdoc
'hits' => [], 'facets' => [], 'meta' => [], ]; } $command = $this->createCommand($db); Yii::trace($command->sql); Yii::trace($command->params); $dataReader = $command->query(); $rawRows = $dataReader->readAll(); $facets = [];
$charact_match_part = implode(' | ', array_keys($char_values)); $match .= ' '.$charact_match_part; } } $query_sphinx->match(new \yii\db\Expression('\''.$match.'\'')); $sphinx_result = $query_sphinx->search(); if (!isset($regions_sphinx_result)) { $regions_sphinx_result = $sphinx_result; } //Yii::error($sphinx_result['hits']); if (count($sphinx_result['hits'])==0 && $at_least_one_word_in_goods_name_title == true) {
public function getGoods($goods_name_model, $search_line = null, $sort = self::SORT_RATING) { $this->search_line = $search_line; $this->gn_id = $goods_name_model->id; $this->charact_models = self::getCharacts($goods_name_model->id); $sphinx_result = $this->searchGoodsSphinxResult($goods_name_model->id, $search_line); if (empty($sphinx_result['hits'])) { return []; } $goods_companies_ids = ArrayHelper::getColumn($sphinx_result['hits'],'id');
if (!empty($search_line)) { yii::$app->statistics->visitSection($goods_name_model->section_id); } $goods = $this->search->getGoods($goods_name_model, $search_line, $sort); // reset($goods); // print_r(current($goods)); return $this->render('goods_name', [ 'goods_name_model' => $goods_name_model, 'sort' => $sort, 'result_rows' => Search::asResultRows($goods),
$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); if ($oldController !== null) { Yii::$app->controller = $oldController; } return $result; }
$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();
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 = [ 'section_slug' => 'obsluzhivanie-i-remont-avtomobilej', 'gn_slug' => 'kolpachok-maslosjemnyj-maslyanyj-zamena', ];