Create a few tables ~ simple explanation, tbl_post Blog table tbl_comment Comment table, tbl_user user table Tbl_tag Tag table run the following SQL directly.
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 (one) not NULL auto_increment,
' Content ' text,
' Status ' tinyint (1) DEFAULT ' 0 ',
' Create_time ' timestamp not NULL the DEFAULT current_timestamp on UPDATE current_timestamp,
' Author ' int (ten) is DEFAULT NULL,
' Email ' char (255) DEFAULT NULL,
' post_id ' int (one) DEFAULT NULL,
PRIMARY KEY (' id ')
) Engine=myisam DEFAULT Charset=utf8;
DROP TABLE IF EXISTS ' tbl_lookup ';
CREATE TABLE ' Tbl_lookup ' (
' id ' int (one) not NULL auto_increment,
' Name ' char (DEFAULT NULL),
' Code ' char (DEFAULT NULL),
' Type ' int (one) DEFAULT NULL,
' Position ' int (one) DEFAULT NULL,
PRIMARY KEY (' id ')
) Engine=myisam DEFAULT Charset=utf8;
DROP TABLE IF EXISTS ' tbl_post ';
CREATE TABLE ' Tbl_post ' (
' id ' int (one) not NULL auto_increment,
' title ' char (DEFAULT NULL),
' Content ' text,
' Tags ' char (255) DEFAULT NULL,
' Status ' tinyint (2) DEFAULT ' 0 ',
' Create_time ' timestamp not NULL the DEFAULT current_timestamp on UPDATE current_timestamp,
' Update_time ' datetime DEFAULT NULL,
' author_id ' int (one) 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 (one) not NULL auto_increment,
' Name ' char (DEFAULT NULL),
' Frequency ' int (one) DEFAULT ' 1 ',
PRIMARY KEY (' id ')
) Engine=myisam DEFAULT Charset=utf8;
DROP TABLE IF EXISTS ' Tbl_user ';
CREATE TABLE ' Tbl_user ' (
' id ' int (one) not NULL auto_increment,
' username ' char (DEFAULT NULL),
' Password ' char (+) DEFAULT NULL,
' Email ' char (+) DEFAULT NULL,
' Sex ' int (one) DEFAULT ' 0 ',
' Profile ' text,
PRIMARY KEY (' id ')
) Engine=myisam auto_increment=3 DEFAULT Charset=utf8;
Insert INTO ' tbl_user ' (' IDs ', ' username ', ' password ', ' email ', ' sex ', ' profile ') VALUES (1, ' admin ', ' e10adc3949ba59abbe56e057f20f883e ', Null,0,null), (2, ' demo ', ' e10adc3949ba59abbe56e057f20f883e ', NULL,0,NULL);
2 Modify the Yii configuration file. protected/config/main.php
About line 50th.
' 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_ '
),
About Line 21st, open 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.html www.bkjia.com true http://www.bkjia.com/PHPjc/477888.html techarticle Create a few tables ~ simple explanation, tbl_post Blog table tbl_comment Comment table, tbl_user user table Tbl_tag Tag table run the following SQL directly. CREATE DATABASE/*!32312 ...