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类和其它模块了。

  • 相关阅读:
    UIWebView 视频播放获取开始播放和结束播放通知
    显示图像数据的高级接口 UIImage
    如何跳到系统设置里的WiFi界面
    Objective-C 去掉NSString 前后中空格
    iOS 属性修饰符的区别
    iOS 线程锁同步机制
    XCode 6 以后使用编程处理一些图片效果
    iOS 精益编程
    iOS7以后UITextView 技巧
    2016年12月英语六级阅读真题及答案 第3套
  • 原文地址:https://www.cnblogs.com/tlnshuju/p/7159121.html
Copyright © 2011-2022 走看看