yii框架之gii创建数据表相应的model类
2017-07-13 10:30 tlnshuju 阅读(296) 评论(0) 收藏 举报一、首先是在数据库中建立project须要的表;
二、然后,配置相应文件:
在project文件夹下yiiProject\protected\config\main.php。在50行定义了db应用组件,以下后一段凝视掉了的mysql的链接配置项。我们将未凝视的db凝视掉,然后打开mysql链接代码并填写相关信息就可以完毕mysql链接配置项。
即。把以下代码
'db'=>array( 'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db', ), // uncomment the following to use a MySQL database /* 'db'=>array( 'connectionString' => 'mysql:host=localhost;dbname=myemail', 'emulatePrepare' => true, 'username' => 'root', 'password' => '123', 'charset' => 'utf8', ), */改为:
/* 'db'=>array( 'connectionString' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db', ), */ // uncomment the following to use a MySQL database 'db'=>array( 'connectionString' => 'mysql:host=localhost;dbname=myemail', 'emulatePrepare' => true, 'username' => 'root', 'password' => '123', 'charset' => 'utf8', ),
三、在project文件夹下yiiblog\protected\config\main.php,在配置文件的21行。将模块配置里的gii部分去掉凝视就可以。
在红色框里填写一个password,使用gii的password。
	'modules'=>array(
		// uncomment the following to enable the Gii tool
		
		'gii'=>array(
			'class'=>'system.gii.GiiModule',
			'password'=>'123',
		 	// If removed, Gii defaults to localhost only. Edit carefully to taste.
			'ipFilters'=>array('127.0.0.1','::1'),
		),
		
	),四、接下来在浏览器中訪问gii模块就可以。訪问路径:http://localhost/yiiProject/index.php?r=gii,输入红色框中定义的密码就可以进入gii模块。脚手架页面的首页显示脚手架提供例如以下功能:以下就能够生成相应数据库表的model类和其它模块了。
 
                    
                 
                
            
         浙公网安备 33010602011771号
浙公网安备 33010602011771号