Internal Server Error
CDbConnection.connectionString cannot be empty.
An internal error occurred while the Web server was processing your request. Please contact the webmaster to report this problem.
Thank you.
①首先是连数据库,出现了以上错误,protected/config/main.php代码如下
return array(
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=yii',
'tablePrefix' =>'yii_',
'emulatePrepare' => true,
'username' => 'root',
'password' => '',
'charset' => 'utf8',
)
);
controller里面一用$connection=Yii::app()->db;就出错,而用显式连接$connection=new CDbConnection('mysql:host=localhost;dbname=yii','root','');就没有问题
②model要引入?已经找遍了各种文档都没有说要引入的。。。。
我protected/models/DataModel.php里面代码如下
class DataModel extends CFormModel
{
public $employeeId;
public $firstName;
public $lastName;
public $title;
public $address;
public $email;
}
而controller里面$model=new DataModel();就报错如下
YiiBase::include(DataModel.php) [<a href='function.YiiBase-include'>function.YiiBase-include</a>]: failed to open stream: No such file or directory
An internal error occurred while the Web server was processing your request. Please contact the webmaster to report this problem.
顺便再求一下YII学习资料文档啊,网上找了好久都是没有入门级或者很繁琐的。因为工作问题,从THINKPHP转学YII,最近几天各种蛋疼,风格始终还没有适应过来