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/Command.php at line 253 yii\db\Connection::getSlavePdo()
    247248249250251252253254255256257258259
                         
            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();
            }
     
            try {
                $this->pdoStatement = $pdo->prepare($sql);
                    
  • 5. in /opt/www/meizhaike/vendor/yiisoft/yii2/db/Command.php at line 1143 yii\db\Command::prepare(true)
    1137113811391140114111421143114411451146114711481149
                                            Yii::debug('Query result served from cache', 'yii\db\Command::query');
                        return $result[0];
                    }
                }
            }
     
            $this->prepare(true);
     
            try {
                $profile and Yii::beginProfile($rawSql, 'yii\db\Command::query');
     
                $this->internalExecute($rawSql);
     
                    
  • 6. in /opt/www/meizhaike/vendor/yiisoft/yii2/db/Command.php at line 425 yii\db\Command::queryInternal('fetchColumn', 0)
    419420421422423424425426427428429430431
                             * @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;
        }
                    
  • 7. in /opt/www/meizhaike/vendor/yiisoft/yii2/db/Query.php at line 463 yii\db\Command::queryScalar()
    457458459460461462463464465466467468469
                         
                $this->select = $select;
                $this->orderBy = $order;
                $this->limit = $limit;
                $this->offset = $offset;
     
                return $command->queryScalar();
            }
     
            $command = (new self())
                ->select([$selectExpression])
                ->from(['c' => $this])
                ->createCommand($db);
                    
  • 8. in /opt/www/meizhaike/vendor/yiisoft/yii2/db/ActiveQuery.php at line 340 yii\db\Query::queryScalar('COUNT(*)', yii\db\Connection)
    334335336337338339340341342343344345346
                                $modelClass = $this->modelClass;
            if ($db === null) {
                $db = $modelClass::getDb();
            }
     
            if ($this->sql === null) {
                return parent::queryScalar($selectExpression, $db);
            }
     
            $command = (new Query())->select([$selectExpression])
                ->from(['c' => "({$this->sql})"])
                ->params($this->params)
                ->createCommand($db);
                    
  • 9. in /opt/www/meizhaike/vendor/yiisoft/yii2/db/Query.php at line 347 yii\db\ActiveQuery::queryScalar('COUNT(*)', yii\db\Connection)
    341342343344345346347348349350351352353
                            public function count($q = '*', $db = null)
        {
            if ($this->emulateExecution) {
                return 0;
            }
     
            return $this->queryScalar("COUNT($q)", $db);
        }
     
        /**
         * Returns the sum of the specified column values.
         * @param string $q the column name or expression.
         * Make sure you properly [quote](guide:db-dao#quoting-table-and-column-names) column names in the expression.
                    
  • 10. in /opt/www/meizhaike/common/models/Designer.php at line 332 yii\db\Query::count()
    326327328329330331332333334335336337338
                                return $get;
        }
     
        public static function getIndexData()
        {
            $designers = self::find()->where(['status' => self::STATUS_ACTIVE, 'company_id' => 1])->orderBy('sort DESC');
            $pages = new Pagination(['totalCount' => $designers->count(), 'pageSize' => '4', 'pageSizeParam' => false]);
            $model = $designers->offset($pages->offset)->limit($pages->limit)->asArray()->all();
            $size = '380x256';
            $designers_data = self::FormatDesignerData($model, '3', $size);
            return ['pages' => $pages, 'designers_data' => $designers_data];
        }
     
                    
  • 11. in /opt/www/meizhaike/frontend/controllers/DesignerController.php at line 31 – common\models\Designer::getIndexData()
    25262728293031323334353637
                                $p = isset($get['page']) ? intval($get['page']) : 1;
            if ($p > 1) {
                $url = Url::to(['designer/designer-list','case'=>0,'type_id'=>0,'level_id'=>0,'style_id'=>0,'page'=>$p]);
                $this->redirect($url);
            }
            $this->layout = 'communal';
            $data = Designer::getIndexData();
            $version = Yii::$app->params['JsCssVersion'];
     
            //tdk
            $view = Yii::$app->getView();
            $view->params['title'] = '家装设计师-家装设计师排行榜-美宅客家装平台';
            $view->params['description'] = '【美宅客】互联网家装平台汇集国内顶尖家装设计师,大咖坐镇为您专案设计 管家服务,设计师量身定制,全程保驾护航!';
                    
  • 12. frontend\controllers\DesignerController::actionIndex()
  • 13. in /opt/www/meizhaike/vendor/yiisoft/yii2/base/InlineAction.php at line 57 – call_user_func_array([frontend\controllers\DesignerController, 'actionIndex'], [])
    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);
        }
    }
                    
  • 14. in /opt/www/meizhaike/vendor/yiisoft/yii2/base/Controller.php at line 157 yii\base\InlineAction::runWithParams(['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 */
                    
  • 15. in /opt/www/meizhaike/vendor/yiisoft/yii2/base/Module.php at line 528 yii\base\Controller::runAction('index', ['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;
            }
                    
  • 16. in /opt/www/meizhaike/vendor/yiisoft/yii2/web/Application.php at line 103 yii\base\Module::runAction('designer/index', ['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) {
                    
  • 17. 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();
                    
  • 18. 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 = [
        's' => '/',
    ];