mysql - CDbConnection.connectionString 不能为空

标签 mysql yii

我现在使用 yii 框架。创建了一个项目名称-“yii”。 在该项目中,我有一个演示文件夹,其中一个是第一个

                         yii/demo/first

在我创建的文件夹中

yii/demo/first/
              ->protected->config->main.php
              ->controller->SiteController.php
              ->view->site->view.php

我还放置了一个屏幕截图在上面显示..

在主文件中,我放置了连接字符串,如屏幕截图所示

enter image description here

我还在mysql中创建了数据库名称为“student”

当我运行这个网站时,我仍然收到类似的错误

enter image description here

我放置的连接字符串仍然显示该错误。

如果上面的代码有任何错误,请告诉我..

最佳答案

您可以在 components 内的 main.php 文件中尝试此代码。

protected /config/main.php

'components' => array(
  'db'=>array(
       // Add hostname, port number, dbnanme
      'connectionString'  => 'mysql:host=hostname;port=5432;dbname=dname',
      'emulatePrepare'    => true,
      'username'          => "username", // Add db Username
      'password'          => "password", // Add Db Password
      'charset'           => 'utf8',
      'schemaCachingDuration' => 3600,
  ),
),

关于mysql - CDbConnection.connectionString 不能为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39383212/

相关文章:

mysql - 在启动 apache solr 之前我应该​​知道什么?

php - 单击按钮时的 Yii CGridView 过滤器

php - SQL/PHP - Between Query with time() 函数

php - Yii 中 findBySQL 的结果

yii - 如何在GridView(yii)中将一列格式化为货币?

yii - Yii-如何使Yii重新发布到 Assets 文件夹

mysql - 对特定列应用 SQL 限制,而不是对完整结果集应用 SQL 限制

python - Django UpdateView 有空表格

php - sql 列出带有左连接的游戏和总评论?

java - Spring JDBC 事务副作用