zoukankan      html  css  js  c++  java
  • yii框架之gii创建数据表相应的model类

    一、首先是在数据库中建立project须要的表;

    二、然后,配置相应文件:

    在project文件夹下yiiProjectprotectedconfigmain.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文件夹下yiiblogprotectedconfigmain.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类和其它模块了。

  • 相关阅读:
    Lilo的实现
    通过Bochs分析Lilo启动Linux内核的过程
    Linux内核代码布局
    Linux启动过程的内核代码分析
    Linux启动过程的C语言代码分析
    Linux操作系统中对于NTFS读取目录功能的实现
    Linux初始化的汇编代码
    Linux文件映射的反思
    Xen的概况
    安装debian总结以及编译linux内核
  • 原文地址:https://www.cnblogs.com/tlnshuju/p/7159121.html
Copyright © 2011-2022 走看看