您好,欢迎访问一九零五行业门户网

php yii框架学习笔记一:入门体验,初次要了解的那些事._PHP教程

创建几张表格~  简单说明一下,tbl_post blog 表 tbl_comment 评论表 , tbl_user 用户表 tbl_tag 标签表直接运行下面的sql 即可.
create database /*!32312 if not exists*/`yii` /*!40100 default character set utf8 */;
use `yii`;
drop table if exists `tbl_comment`;
create table `tbl_comment` (
  `id` int(11) not null auto_increment,
  `content` text,
  `status` tinyint(1) default '0',
  `create_time` timestamp not null default current_timestamp on update current_timestamp,
  `author` int(10) default null,
  `email` char(255) default null,
  `post_id` int(11) default null,
  primary key (`id`)
) engine=myisam default charset=utf8;
drop table if exists `tbl_lookup`;
create table `tbl_lookup` (
  `id` int(11) not null auto_increment,
  `name` char(20) default null,
  `code` char(20) default null,
  `type` int(11) default null,
  `position` int(11) default null,
  primary key (`id`)
) engine=myisam default charset=utf8;
drop table if exists `tbl_post`;
create table `tbl_post` (
  `id` int(11) not null auto_increment,
  `title` char(20) default null,
  `content` text,
  `tags` char(255) default null,
  `status` tinyint(2) default '0',
  `create_time` timestamp not null default current_timestamp on update current_timestamp,
  `update_time` datetime default null,
  `author_id` int(11) default null,
  primary key (`id`)
) engine=myisam auto_increment=2 default charset=utf8;
/*data for the table `tbl_post` */
insert  into `tbl_post`(`id`,`title`,`content`,`tags`,`status`,`create_time`,`update_time`,`author_id`) values (1,'111','222222','3333',1,'2012-08-08 00:00:00','2012-08-08 00:00:00',2);
/*table structure for table `tbl_tag` */
drop table if exists `tbl_tag`;
create table `tbl_tag` (
  `id` int(11) not null auto_increment,
  `name` char(20) default null,
  `frequency` int(11) default '1',
  primary key (`id`)
) engine=myisam default charset=utf8;
drop table if exists `tbl_user`;
create table `tbl_user` (
  `id` int(11) not null auto_increment,
  `username` char(20) default null,
  `password` char(32) default null,
  `email` char(100) default null,
  `sex` int(11) default '0',
  `profile` text,
  primary key (`id`)
) engine=myisam auto_increment=3 default charset=utf8;
insert  into `tbl_user`(`id`,`username`,`password`,`email`,`sex`,`profile`) values (1,'admin','e10adc3949ba59abbe56e057f20f883e',null,0,null),(2,'demo','e10adc3949ba59abbe56e057f20f883e',null,0,null);
2 修改yii 的配置文件. protected/config/main.php
//约第五十行。
//  'db'=>array(
//   'connectionstring' => 'sqlite:'.dirname(__file__).'/../data/testdrive.db',
//  ),
  // uncomment the following to use a mysql database
  'db'=>array(
   'connectionstring' => 'mysql:host=192.168.1.33;dbname=yii',
   'emulateprepare' => true,
   'username' => 'root',
   'password' => 'admin',
   'charset' => 'utf8',  'prefix' => 'tbl'
            'tableprefix'=>'tbl_'
  ),
//约第21行,打开gii~
'modules'=>array(
  // uncomment the following to enable the gii tool
  'gii'=>array(
   'class'=>'system.gii.giimodule',
   'password'=>'123456',
   // if removed, gii defaults to localhost only. edit carefully to taste.
     'ipfilters'=>array('127.0.0.1','192.168.1.7'),
  ),
 ),
         $user = user::model()->findbyattributes(array('username' => $this->username));
        if ($user === null) {
                $this->errorcode = self::error_username_invalid;
        } else if ($user->password !== md5(trim($this->password))) {
                $this->errorcode = self::error_password_invalid;
        } else {
                $this->setstate('id', $user->id);
                $this->setstate('username', $user->username);
                $this->errorcode = self::error_none;
        }
        return !$this->errorcode;
http://www.bkjia.com/phpjc/477888.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/477888.htmltecharticle创建几张表格~ 简单说明一下, tbl_post blog 表 tbl_comment 评论表 , tbl_user 用户表 tbl_tag 标签表 直接运行下面的sql 即可. create database /*!32312...
其它类似信息

推荐信息