Copied! Copy Stacktrace Search Stackoverflow Search Google Exception

Database Exceptionyii\db\Exception

SQLSTATE[HY000] [1049] Unknown database 'meizhaike'

  • 1. in /opt/www/meizhaike/vendor/yiisoft/yii2/db/Connection.php at line 624
    615616617618619620621622623624625626627628629630631632633
                         
                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()
        {
                    
  • 2. in /opt/www/meizhaike/vendor/yiisoft/yii2/db/Connection.php at line 996 yii\db\Connection::open()
    990991992993994995996997998999100010011002
                             * 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.
                    
  • 3. in /opt/www/meizhaike/vendor/yiisoft/yii2/db/Connection.php at line 983 yii\db\Connection::getMasterPdo()
    977978979980981982983984985986987988989
                             * 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;
        }
     
        /**
                    
  • 4. in /opt/www/meizhaike/vendor/yiisoft/yii2/db/Schema.php at line 463 yii\db\Connection::getSlavePdo()
    457458459460461462463464465466467468469
                            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") . "'";
        }
                    
  • 5. in /opt/www/meizhaike/vendor/yiisoft/yii2/db/Connection.php at line 881 yii\db\Schema::quoteValue('shanghai')
    875876877878879880881882883884885886887
                             * @param string $value string to be quoted
         * @return string the properly quoted string
         * @see http://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 '{{',
                    
  • 6. in /opt/www/meizhaike/vendor/yiisoft/yii2/db/Command.php at line 209 yii\db\Connection::quoteValue('shanghai')
    203204205206207208209210211212213214215
                                $params = [];
            foreach ($this->params as $name => $value) {
                if (is_string($name) && strncmp(':', $name, 1)) {
                    $name = ':' . $name;
                }
                if (is_string($value)) {
                    $params[$name] = $this->db->quoteValue($value);
                } elseif (is_bool($value)) {
                    $params[$name] = ($value ? 'TRUE' : 'FALSE');
                } elseif ($value === null) {
                    $params[$name] = 'NULL';
                } elseif ((!is_object($value) && !is_resource($value)) || $value instanceof Expression) {
                    $params[$name] = $value;
                    
  • 7. in /opt/www/meizhaike/vendor/yiisoft/yii2/db/Command.php at line 1099 yii\db\Command::getRawSql()
    1093109410951096109710981099110011011102110311041105
                             * @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.
         */
        private function logQuery($category)
        {
            if ($this->db->enableLogging) {
                $rawSql = $this->getRawSql();
                Yii::info($rawSql, $category);
            }
            if (!$this->db->enableProfiling) {
                return [false, isset($rawSql) ? $rawSql : null];
            }
     
                    
  • 8. in /opt/www/meizhaike/vendor/yiisoft/yii2/db/Command.php at line 1120 – yii\db\Command::logQuery('yii\db\Command::query')
    1114111511161117111811191120112111221123112411251126
                             * @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];
                    
  • 9. in /opt/www/meizhaike/vendor/yiisoft/yii2/db/Command.php at line 413 yii\db\Command::queryInternal('fetch', null)
    407408409410411412413414415416417418419
                             * @return array|false the first row (in terms of an array) of the query result. False is returned if the query
         * results in nothing.
         * @throws Exception execution failed
         */
        public function queryOne($fetchMode = null)
        {
            return $this->queryInternal('fetch', $fetchMode);
        }
     
        /**
         * Executes the SQL statement and returns the value of the first column in the first row of data.
         * This method is best used when only a single value is needed for a query.
         * @return string|null|false the value of the first column in the first row of the query result.
                    
  • 10. in /opt/www/meizhaike/vendor/yiisoft/yii2/db/Query.php at line 274 yii\db\Command::queryOne()
    268269270271272273274275276277278279280
                            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.
                    
  • 11. in /opt/www/meizhaike/vendor/yiisoft/yii2/db/ActiveQuery.php at line 292 yii\db\Query::one(null)
    286287288289290291292293294295296297298
                             * @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;
                    
  • 12. in /opt/www/meizhaike/common/models/AreaStation.php at line 101 yii\db\ActiveQuery::one()
    9596979899100101102103104105106107
                                }
            return $statusText;
        }
     
        public static function getId($pinyin)
        {
            return self::find()->select('id')->where(['pinyin' => $pinyin])->one()['id'];
        }
     
        public static function getCitys($select = true, $condition = 'name,pinyin')
        {
            if ($select){
                return self::find()->select($condition)->where(['type'=>1])->asArray()->all();
                    
  • 13. in /opt/www/meizhaike/frontend/controllers/CompanyController.php at line 48 – common\models\AreaStation::getId('shanghai')
    42434445464748495051525354
                                $city_id = isset($get['city_id']) ? intval($get['city_id']) : '';
            $skills = isset($get['skills']) ? intval($get['skills']) : '';
            $server_area = isset($get['server_area']) ? intval($get['server_area']) : '';
            $price = isset($get['price']) ? intval($get['price']) : '';
            $location = isset($get['location']) ? intval($get['location']) : '';
            $style = isset($get['style']) ? intval($get['style']) : '';
            $id = intval(AreaStation::getId($city));
     
            $paramKey = RedisKey::CP . $city . '_' . $city_id . $skills . $server_area . $price . $style . $location . $page;
            $search_key = RedisKey::SEARCH_DATA_ID . $id . "_key";
            $redis = Redis::getRedis();
            try {
                if(Yii::$app->params['redisOpen']) {
                    
  • 14. frontend\controllers\CompanyController::actionCompanyList()
  • 15. in /opt/www/meizhaike/vendor/yiisoft/yii2/base/InlineAction.php at line 57 – call_user_func_array([frontend\controllers\CompanyController, 'actionCompanyList'], [])
    515253545556575859
                                $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);
        }
    }
                    
  • 16. in /opt/www/meizhaike/vendor/yiisoft/yii2/base/Controller.php at line 157 yii\base\InlineAction::runWithParams(['city' => 'shanghai', 's' => '/'])
    151152153154155156157158159160161162163
                                }
     
            $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 */
                    
  • 17. in /opt/www/meizhaike/vendor/yiisoft/yii2/base/Module.php at line 528 yii\base\Controller::runAction('company-list', ['city' => 'shanghai', 's' => '/'])
    522523524525526527528529530531532533534
                                $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;
            }
                    
  • 18. in /opt/www/meizhaike/vendor/yiisoft/yii2/web/Application.php at line 103 yii\base\Module::runAction('company/company-list', ['city' => 'shanghai', 's' => '/'])
    979899100101102103104105106107108109
                                    $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) {
                    
  • 19. in /opt/www/meizhaike/vendor/yiisoft/yii2/base/Application.php at line 386 yii\web\Application::handleRequest(yii\web\Request)
    380381382383384385386387388389390391392
                            {
            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();
                    
  • 20. in /opt/www/meizhaike/frontend/web/index.php at line 17 yii\base\Application::run()
    11121314151617
                            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 = [
        'city' => 'shanghai',
    ];