in /usr/local/etc/rostislav/vendor_new/yiisoft/yii2/db/Connection.php at line 705
if ($enableProfiling) { Yii::endProfile($token, __METHOD__); } } catch (\PDOException $e) { if ($enableProfiling) { 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; } return $db->pdo; } /**
public function quoteValue($str) { if (!is_string($str)) { return $str; } if (($value = $this->db->getSlavePdo()->quote($str)) !== false) { return $value; } // the driver doesn't support quote (e.g. oci) return "'" . addcslashes(str_replace("'", "''", $str), "\000\n\r\\\032") . "'"; }
* @param string $value string to be quoted * @return string the properly quoted string * @see https://secure.php.net/manual/en/pdo.quote.php */ public function quoteValue($value) { return $this->getSchema()->quoteValue($value); } /** * Quotes a table name for use in a query. * If the table name contains schema prefix, the prefix will also be properly quoted. * If the table name is already quoted or contains special characters including '(', '[[' and '{{',
$params = []; foreach ($this->params as $name => $value) { if (is_string($name) && strncmp(':', $name, 1)) { $name = ':' . $name; } if (is_string($value) || $value instanceof Expression) { $params[$name] = $this->db->quoteValue((string)$value); } elseif (is_bool($value)) { $params[$name] = ($value ? 'TRUE' : 'FALSE'); } elseif ($value === null) { $params[$name] = 'NULL'; } elseif (!is_object($value) && !is_resource($value)) { $params[$name] = $value;
* @return array array of two elements, the first is boolean of whether profiling is enabled or not. * The second is the rawSql if it has been created. */ protected function logQuery($category) { if ($this->db->enableLogging) { $rawSql = $this->getRawSql(); Yii::info($rawSql, $category); } if (!$this->db->enableProfiling) { return [false, isset($rawSql) ? $rawSql : null]; }
* @return mixed the method execution result * @throws Exception if the query causes any problem * @since 2.0.1 this method is protected (was private before). */ protected function queryInternal($method, $fetchMode = null) { list($profile, $rawSql) = $this->logQuery('yii\db\Command::query'); if ($method !== '') { $info = $this->db->getQueryCacheInfo($this->queryCacheDuration, $this->queryCacheDependency); if (is_array($info)) { /* @var $cache \yii\caching\CacheInterface */ $cache = $info[0];
* @return string|null|false the value of the first column in the first row of the query result. * False is returned if there is no value. * @throws Exception execution failed */ public function queryScalar() { $result = $this->queryInternal('fetchColumn', 0); if (is_resource($result) && get_resource_type($result) === 'stream') { return stream_get_contents($result); } return $result; }
public function scalar($db = null) { if ($this->emulateExecution) { return null; } return $this->createCommand($db)->queryScalar(); } /** * Executes the query and returns the first column of the result. * @param Connection $db the database connection used to generate the SQL statement. * If this parameter is not given, the `db` application component will be used.
public function bootstrap($app) { $canonical = ModelSeoCanonical::find()->where([ 'state' => ModelSeoCanonical::STATE_VALID, 'hash' => md5(\Yii::$app->getRequest()->absoluteUrl), ])->select('to')->scalar(); if ($canonical) { \Yii::$app->view->registerLinkTag(['rel' => 'canonical', 'href' => $canonical]); } }
if (!isset($component)) { $component = Yii::createObject($mixed); } if ($component instanceof BootstrapInterface) { Yii::debug('Bootstrap with ' . get_class($component) . '::bootstrap()', __METHOD__); $component->bootstrap($this); } else { Yii::debug('Bootstrap with ' . get_class($component), __METHOD__); } } }
protected function bootstrap() { $request = $this->getRequest(); Yii::setAlias('@webroot', dirname($request->getScriptFile())); Yii::setAlias('@web', $request->getBaseUrl()); parent::bootstrap(); } /** * Handles the specified request. * @param Request $request the request to be handled * @return Response the resulting response
/** * {@inheritdoc} */ public function init() { $this->state = self::STATE_INIT; $this->bootstrap(); } /** * Initializes extensions and executes bootstrap components. * This method is called by [[init()]] after the application has been fully configured. * If you override this method, make sure you also call the parent implementation.
*/ public function __construct($config = []) { if (!empty($config)) { Yii::configure($this, $config); } $this->init(); } /** * Initializes the object. * This method is invoked at the end of the constructor after the object is initialized with the * given configuration.
$this->state = self::STATE_BEGIN; $this->preInit($config); $this->registerErrorHandler($config); Component::__construct($config); } /** * Pre-initializes the application. * This method is called at the beginning of the application constructor. * It initializes several important application properties.
// error_reporting(E_ALL); $config['bootstrap'][] = 'gii'; $config['modules']['gii'] = ['class' => 'yii\gii\Module']; } (new yii\web\Application($config))->run(); //if (YII_ENV == 'dev') { // //} else { // if (ob_start("optimizerImageWebp")) { // (new yii\web\Application($config))->run();