CREATE TABLE IF NOT EXISTS `pw_house_expired` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `datatype` tinyint(1) NOT NULL DEFAULT '0',
  `expiredtype` tinyint(1) NOT NULL DEFAULT '0',
  `houseid` int(10) NOT NULL DEFAULT '0',
  `expiredtime` int(10) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  UNIQUE KEY `datatype` (`datatype`,`houseid`,`expiredtype`),
  KEY `expiredtime` (`expiredtime`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS `pw_house_secondpost` (
  `uid` int(10) NOT NULL DEFAULT '0',
  `salenum` int(10) NOT NULL DEFAULT '0',
  `hirenum` int(10) NOT NULL DEFAULT '0',
  `todaysalenum` smallint(6) NOT NULL DEFAULT '0',
  `lastsaletime` int(10) NOT NULL DEFAULT '0',
  `todayhirenum` smallint(10) NOT NULL DEFAULT '0',
  `lasthiretime` int(10) NOT NULL DEFAULT '0',
  `ifbroker` tinyint(3) NOT NULL DEFAULT '0',
  PRIMARY KEY (`uid`),
  KEY `idx_salenum` (`salenum`),
  KEY `idx_hirenum` (`hirenum`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS `pw_house_saleinfo` (
  `houseid` int(8) NOT NULL AUTO_INCREMENT,
  `areatype` tinyint(3) NOT NULL DEFAULT '0',
  `platetype` tinyint(3) NOT NULL DEFAULT '0',
  `pricetype` tinyint(3) NOT NULL DEFAULT '0',
  `acreagetype` tinyint(3) NOT NULL DEFAULT '0',
  `roomtype` tinyint(3) NOT NULL DEFAULT '0',
  `housetype` tinyint(3) NOT NULL DEFAULT '0',
  `subject` varchar(100) NOT NULL DEFAULT ' ',
  `uid` int(10) NOT NULL DEFAULT '0',
  `username` varchar(15) NOT NULL DEFAULT ' ',
  `istop` tinyint(3) NOT NULL DEFAULT '0',
  `isurgent` tinyint(3) NOT NULL DEFAULT '0',
  `isbroker` tinyint(3) NOT NULL DEFAULT '0',
  `acreage` float NOT NULL DEFAULT '0',
  `currentfloor` tinyint(3) NOT NULL DEFAULT '0',
  `totalfloor` tinyint(3) NOT NULL DEFAULT '0',
  `price` int(10) NOT NULL DEFAULT '0',
  `unitprice` int(10) NOT NULL DEFAULT '0',
  `room` smallint(6) NOT NULL DEFAULT '0',
  `righter` tinyint(3) NOT NULL DEFAULT '0',
  `village` varchar(50) NOT NULL DEFAULT ' ',
  `address` varchar(50) NOT NULL DEFAULT ' ',
  `buildtime` smallint(6) NOT NULL DEFAULT '0',
  `traffic` varchar(100) NOT NULL DEFAULT ' ',
  `fitment` tinyint(3) NOT NULL DEFAULT '0',
  `equipment` varchar(50) NOT NULL DEFAULT ' ',
  `thumb` varchar(50) NOT NULL DEFAULT ' ',
  `state` tinyint(3) NOT NULL DEFAULT '0',
  `descrip` text CHARACTER SET gbk,
  `gate` varchar(200) NOT NULL DEFAULT ' ',
  `linkman` varchar(50) NOT NULL DEFAULT ' ',
  `posttime` int(10) NOT NULL DEFAULT '0',
  `modifytime` int(10) NOT NULL DEFAULT '0',
  PRIMARY KEY (`houseid`),
  KEY `idx_modifytime` (`modifytime`),
  KEY `idx_posttime` (`posttime`),
  KEY `idx_uid` (`uid`),
  KEY `idx_status` (`state`),
  KEY `idx_price` (`price`),
  KEY `idx_unitprice` (`unitprice`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS `pw_house_salemodifytime_index` (
  `houseid` int(8) NOT NULL,
  `areatype` tinyint(3) NOT NULL DEFAULT '0',
  `platetype` tinyint(3) NOT NULL DEFAULT '0',
  `pricetype` tinyint(3) NOT NULL DEFAULT '0',
  `acreagetype` tinyint(3) NOT NULL DEFAULT '0',
  `roomtype` tinyint(3) NOT NULL DEFAULT '0',
  `housetype` tinyint(3) NOT NULL DEFAULT '0',
  `modifytime` int(10) NOT NULL DEFAULT '0',
  KEY `idx_houseid` (`houseid`),
  KEY `idx_price_acreage_room_house_modifytime` (`pricetype`,`acreagetype`,`roomtype`,`housetype`,`modifytime`),
  KEY `idx_acreage_room_house_modifytime` (`acreagetype`,`roomtype`,`housetype`,`modifytime`),
  KEY `idx_room_house_modifytime` (`roomtype`,`housetype`,`modifytime`),
  KEY `idx_house_modifytime` (`housetype`,`modifytime`),
  KEY `idx_area_plate_price_acreage_room_house_modifytime` (`areatype`,`platetype`,`pricetype`,`acreagetype`,`roomtype`,`housetype`,`modifytime`),
  KEY `idx_plate_price_acreage_room_house_modifytime` (`platetype`,`pricetype`,`acreagetype`,`roomtype`,`housetype`,`modifytime`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS `pw_house_saleoverdue` (
  `houseid` int(8) NOT NULL DEFAULT '0',
  `areatype` tinyint(3) NOT NULL DEFAULT '0',
  `platetype` tinyint(3) NOT NULL DEFAULT '0',
  `pricetype` tinyint(3) NOT NULL DEFAULT '0',
  `acreagetype` tinyint(3) NOT NULL DEFAULT '0',
  `roomtype` tinyint(3) NOT NULL DEFAULT '0',
  `housetype` tinyint(3) NOT NULL DEFAULT '0',
  `modifytime` int(10) NOT NULL DEFAULT '0',
  `posttime` int(10) NOT NULL DEFAULT '0',
  `price` int(10) NOT NULL DEFAULT '0',
  `unitprice` int(10) NOT NULL DEFAULT '0',
  KEY `idx_houseid` (`houseid`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS `pw_house_saleposttime_index` (
  `houseid` int(8) NOT NULL,
  `areatype` tinyint(3) NOT NULL DEFAULT '0',
  `platetype` tinyint(3) NOT NULL DEFAULT '0',
  `pricetype` tinyint(3) NOT NULL DEFAULT '0',
  `acreagetype` tinyint(3) NOT NULL DEFAULT '0',
  `roomtype` tinyint(3) NOT NULL DEFAULT '0',
  `housetype` tinyint(3) NOT NULL DEFAULT '0',
  `posttime` int(10) NOT NULL DEFAULT '0',
  KEY `idx_houseid` (`houseid`),
  KEY `idx_price_acreage_room_house_posttime` (`pricetype`,`acreagetype`,`roomtype`,`housetype`,`posttime`),
  KEY `idx_acreage_room_house_posttime` (`acreagetype`,`roomtype`,`housetype`,`posttime`),
  KEY `idx_room_house_posttime` (`roomtype`,`housetype`,`posttime`),
  KEY `idx_house_posttime` (`housetype`,`posttime`),
  KEY `idx_plate_price_acreage_room_house_posttime` (`platetype`,`pricetype`,`acreagetype`,`roomtype`,`housetype`,`posttime`),
  KEY `idx_area_plate_price_acreage_room_house_posttime` (`areatype`,`platetype`,`pricetype`,`acreagetype`,`roomtype`,`housetype`,`posttime`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS `pw_house_saleprice_index` (
  `houseid` int(8) NOT NULL,
  `areatype` tinyint(3) NOT NULL DEFAULT '0',
  `platetype` tinyint(3) NOT NULL DEFAULT '0',
  `pricetype` tinyint(3) NOT NULL DEFAULT '0',
  `acreagetype` tinyint(3) NOT NULL DEFAULT '0',
  `roomtype` tinyint(3) NOT NULL DEFAULT '0',
  `housetype` tinyint(3) NOT NULL DEFAULT '0',
  `price` int(10) NOT NULL DEFAULT '0',
  KEY `idx_houseid` (`houseid`),
  KEY `idx_price_acreage_room_house_price` (`pricetype`,`acreagetype`,`roomtype`,`housetype`,`price`),
  KEY `idx_acreage_room_house_price` (`acreagetype`,`roomtype`,`housetype`,`price`),
  KEY `idx_room_house_price` (`roomtype`,`housetype`,`price`),
  KEY `idx_house_price` (`housetype`,`price`),
  KEY `idx_area_plate_price_acreage_room_house_price` (`areatype`,`platetype`,`pricetype`,`acreagetype`,`roomtype`,`housetype`,`price`),
  KEY `idx_plate_price_acreage_room_house_price` (`platetype`,`pricetype`,`acreagetype`,`roomtype`,`housetype`,`price`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS `pw_house_saleunitprice_index` (
  `houseid` int(8) NOT NULL,
  `areatype` tinyint(3) NOT NULL DEFAULT '0',
  `platetype` tinyint(3) NOT NULL DEFAULT '0',
  `pricetype` tinyint(3) NOT NULL DEFAULT '0',
  `acreagetype` tinyint(3) NOT NULL DEFAULT '0',
  `roomtype` tinyint(3) NOT NULL DEFAULT '0',
  `housetype` tinyint(3) NOT NULL DEFAULT '0',
  `unitprice` int(10) NOT NULL DEFAULT '0',
  KEY `idx_houseid` (`houseid`),
  KEY `idx_price_acreage_room_house_unitprice` (`pricetype`,`acreagetype`,`roomtype`,`housetype`,`unitprice`),
  KEY `idx_acreage_room_house_unitprice` (`acreagetype`,`roomtype`,`housetype`,`unitprice`),
  KEY `idx_room_house_unitprice` (`roomtype`,`housetype`,`unitprice`),
  KEY `idx_house_unitprice` (`housetype`,`unitprice`),
  KEY `idx_area_plate_price_acreage_room_house_unitprice` (`areatype`,`platetype`,`pricetype`,`acreagetype`,`roomtype`,`housetype`,`unitprice`),
  KEY `idx_plate_price_acreage_room_house_unitprice` (`platetype`,`pricetype`,`acreagetype`,`roomtype`,`housetype`,`unitprice`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS `pw_house_hireinfo` (
  `houseid` int(8) NOT NULL AUTO_INCREMENT,
  `areatype` tinyint(3) NOT NULL DEFAULT '0',
  `platetype` tinyint(3) NOT NULL DEFAULT '0',
  `pricetype` tinyint(3) NOT NULL DEFAULT '0',
  `housetype` tinyint(3) NOT NULL DEFAULT '0',
  `roomtype` tinyint(3) NOT NULL DEFAULT '0',
  `hiretype` tinyint(3) NOT NULL DEFAULT '0',
  `subject` varchar(100) NOT NULL DEFAULT ' ',
  `uid` int(10) NOT NULL DEFAULT '0',
  `username` varchar(15) NOT NULL DEFAULT ' ',
  `ischarge` tinyint(3) NOT NULL DEFAULT '0',
  `istop` tinyint(3) NOT NULL DEFAULT '0',
  `isurgent` tinyint(3) NOT NULL,
  `isbroker` tinyint(3) NOT NULL DEFAULT '0',
  `acreage` float NOT NULL DEFAULT '0',
  `currentfloor` tinyint(3) NOT NULL DEFAULT '0',
  `totalfloor` tinyint(3) NOT NULL DEFAULT '0',
  `price` int(10) NOT NULL DEFAULT '0',
  `room` smallint(6) NOT NULL DEFAULT '0',
  `village` varchar(50) NOT NULL DEFAULT ' ',
  `address` varchar(50) NOT NULL DEFAULT ' ',
  `buildtime` smallint(6) NOT NULL DEFAULT '0',
  `traffic` varchar(100) NOT NULL DEFAULT ' ',
  `fitment` tinyint(3) NOT NULL DEFAULT '0',
  `equipment` varchar(20) NOT NULL DEFAULT ' ',
  `thumb` varchar(50) NOT NULL DEFAULT ' ',
  `state` tinyint(1) NOT NULL DEFAULT '0',
  `descrip` text,
  `gate` varchar(200) NOT NULL DEFAULT ' ',
  `linkman` varchar(50) NOT NULL DEFAULT ' ',
  `posttime` int(10) NOT NULL DEFAULT '0',
  `modifytime` int(10) NOT NULL DEFAULT '0',
  PRIMARY KEY (`houseid`),
  KEY `idx_modifytime` (`modifytime`),
  KEY `idx_posttime` (`posttime`),
  KEY `idx_uid` (`uid`),
  KEY `idx_state` (`state`),
  KEY `idx_price` (`price`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS `pw_house_hiremodifytime_index` (
  `houseid` int(8) NOT NULL,
  `areatype` tinyint(3) NOT NULL DEFAULT '0',
  `platetype` tinyint(3) NOT NULL DEFAULT '0',
  `pricetype` tinyint(3) NOT NULL DEFAULT '0',
  `housetype` tinyint(3) NOT NULL DEFAULT '0',
  `roomtype` tinyint(3) NOT NULL DEFAULT '0',
  `hiretype` tinyint(3) NOT NULL DEFAULT '0',
  `modifytime` int(10) NOT NULL DEFAULT '0',
  KEY `idx_houseid` (`houseid`),
  KEY `idx_price_house_room_hire_modifytime` (`pricetype`,`housetype`,`roomtype`,`hiretype`,`modifytime`),
  KEY `idx_house_room_hire_modifytime` (`housetype`,`roomtype`,`hiretype`,`modifytime`),
  KEY `idx_room_hire_modifytime` (`roomtype`,`hiretype`,`modifytime`),
  KEY `idx_hire_modifytime` (`hiretype`,`modifytime`),
  KEY `idx_area_plate_price_house_room_hire_modifytime` (`areatype`,`platetype`,`pricetype`,`housetype`,`roomtype`,`hiretype`,`modifytime`),
  KEY `idx_plate_price_house_room_hire_modifytime` (`platetype`,`pricetype`,`housetype`,`roomtype`,`hiretype`,`modifytime`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS `pw_house_hireoverdue` (
  `houseid` int(8) NOT NULL DEFAULT '0',
  `areatype` tinyint(3) NOT NULL DEFAULT '0',
  `platetype` tinyint(3) NOT NULL DEFAULT '0',
  `pricetype` tinyint(3) NOT NULL DEFAULT '0',
  `housetype` tinyint(3) NOT NULL DEFAULT '0',
  `roomtype` tinyint(3) NOT NULL DEFAULT '0',
  `hiretype` tinyint(3) NOT NULL DEFAULT '0',
  `posttime` int(10) NOT NULL DEFAULT '0',
  `modifytime` int(10) NOT NULL DEFAULT '0',
  `price` int(10) NOT NULL DEFAULT '0',
  KEY `idx_houseid` (`houseid`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS `pw_house_hireposttime_index` (
  `houseid` int(8) NOT NULL,
  `areatype` tinyint(3) NOT NULL DEFAULT '0',
  `platetype` tinyint(3) NOT NULL DEFAULT '0',
  `pricetype` tinyint(3) NOT NULL DEFAULT '0',
  `housetype` tinyint(3) NOT NULL DEFAULT '0',
  `roomtype` tinyint(3) NOT NULL DEFAULT '0',
  `hiretype` tinyint(3) NOT NULL DEFAULT '0',
  `posttime` int(10) NOT NULL DEFAULT '0',
  KEY `idx_houseid` (`houseid`),
  KEY `idx_price_house_room_hire_posttime` (`pricetype`,`housetype`,`roomtype`,`hiretype`,`posttime`),
  KEY `idx_house_room_hire_posttime` (`housetype`,`roomtype`,`hiretype`,`posttime`),
  KEY `idx_room_hire_posttime` (`roomtype`,`hiretype`,`posttime`),
  KEY `idx_hire_posttime` (`hiretype`,`posttime`),
  KEY `idx_area_plate_price_house_room_hire_posttime` (`areatype`,`platetype`,`pricetype`,`housetype`,`roomtype`,`hiretype`,`posttime`),
  KEY `idx_plate_price_house_room_hire_posttime` (`platetype`,`pricetype`,`housetype`,`roomtype`,`hiretype`,`posttime`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS `pw_house_hireprice_index` (
  `houseid` int(8) NOT NULL,
  `areatype` tinyint(3) NOT NULL DEFAULT '0',
  `platetype` tinyint(3) NOT NULL DEFAULT '0',
  `pricetype` tinyint(3) NOT NULL DEFAULT '0',
  `housetype` tinyint(3) NOT NULL DEFAULT '0',
  `roomtype` tinyint(3) NOT NULL DEFAULT '0',
  `hiretype` tinyint(3) NOT NULL DEFAULT '0',
  `price` int(10) NOT NULL DEFAULT '0',
  KEY `idx_houseid` (`houseid`),
  KEY `idx_price_house_room_hire_price` (`pricetype`,`housetype`,`roomtype`,`hiretype`,`price`),
  KEY `idx_house_room_hire_price` (`housetype`,`roomtype`,`hiretype`,`price`),
  KEY `idx_room_hire_price` (`roomtype`,`hiretype`,`price`),
  KEY `idx_hire_price` (`hiretype`,`price`),
  KEY `idx_area_plate_price_house_room_hire_price` (`areatype`,`platetype`,`pricetype`,`housetype`,`roomtype`,`hiretype`,`price`),
  KEY `idx_plate_price_house_room_hire_price` (`platetype`,`pricetype`,`housetype`,`roomtype`,`hiretype`,`price`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS `pw_house_personal` (
  `houseid` int(10) NOT NULL DEFAULT '0',
  `datatype` tinyint(1) NOT NULL DEFAULT '0',
  `linkman` varchar(50) NOT NULL DEFAULT ' ',
  `phone` varchar(15) NOT NULL DEFAULT ' ',
  `tel` varchar(15) NOT NULL DEFAULT ' ',
  `email` varchar(50) NOT NULL DEFAULT ' ',
  KEY `idx_houseid` (`houseid`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS `pw_house_secondimage` (
  `imageid` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `type` tinyint(3) unsigned NOT NULL DEFAULT '0',
  `houseid` int(10) unsigned NOT NULL DEFAULT '0',
  `size` int(10) unsigned NOT NULL DEFAULT '0',
  `path` varchar(100) NOT NULL DEFAULT '',
  `uploadtime` int(10) NOT NULL DEFAULT '0',
  `descrip` varchar(255) NOT NULL DEFAULT '',
  `creator` varchar(20) NOT NULL DEFAULT '',
  `name` varchar(30) NOT NULL DEFAULT '',
  PRIMARY KEY (`imageid`),
  KEY `idx_type` (`type`,`houseid`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS `pw_house_report` (
  `reportid` mediumint(8) NOT NULL AUTO_INCREMENT,
  `uid` int(10) NOT NULL DEFAULT '0',
  `username` varchar(15) NOT NULL DEFAULT '',
  `reason` text NOT NULL,
  `handle` tinyint(3) NOT NULL DEFAULT '0',
  `type` tinyint(3) NOT NULL DEFAULT '0',
  `id` int(10) NOT NULL DEFAULT '0',
  `time` int(10) NOT NULL DEFAULT '0',
  PRIMARY KEY (`reportid`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS `pw_house_brokergroup` (
  `groupid` tinyint(3) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(30) NOT NULL DEFAULT '',
  `usernum` smallint(6) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`groupid`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS `pw_house_brokerright` (
  `groupid` tinyint(3) unsigned NOT NULL DEFAULT '0',
  `rightkey` varchar(30) NOT NULL,
  `rightvalue` varchar(30) NOT NULL,
  UNIQUE KEY `groupid` (`groupid`,`rightkey`)
) ENGINE=MyISAM;

CREATE TABLE IF NOT EXISTS `pw_house_broker` (
  `uid` int(10) NOT NULL DEFAULT '0',
  `username` varchar(15) NOT NULL DEFAULT '',
  `groupid` tinyint(3) unsigned NOT NULL DEFAULT '0',
  `realname` varchar(30) NOT NULL DEFAULT '',
  `ifactive` tinyint(3) NOT NULL DEFAULT '1',
  `area` int(10) NOT NULL DEFAULT '0',
  `plate` text NOT NULL,
  `company` varchar(30) NOT NULL DEFAULT '',
  `address` varchar(150) NOT NULL DEFAULT '',
  `email` varchar(50) NOT NULL DEFAULT '',
  `tel` varchar(15) NOT NULL DEFAULT '',
  `phone` varchar(15) NOT NULL DEFAULT '',
  `verify` int(10) unsigned NOT NULL DEFAULT '0',
  `idcard` char(18) NOT NULL DEFAULT '',
  `idcardpic` varchar(100) NOT NULL DEFAULT '',
  `alipay` varchar(50) NOT NULL DEFAULT '',
  `otherinfo` varchar(255) NOT NULL DEFAULT '',
  `remark` varchar(255) NOT NULL DEFAULT '',
  `createtime` int(10) unsigned NOT NULL DEFAULT '0',
  `announce` text,
  `business` char(4) DEFAULT '',
  KEY `idx_uid` (`uid`),
  KEY `idx_createtime` (`createtime`),
  KEY `idx_groupid` (`groupid`),
  KEY `idx_username` (`username`),
  KEY `idx_realname` (`realname`)
) ENGINE=MyISAM;

CREATE TABLE `pw_house_area` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `code` varchar(8) NOT NULL,
  `name` varchar(60) NOT NULL,
  `ifopen` tinyint(1) NOT NULL,
  PRIMARY KEY (`id`),
  UNIQUE KEY `code` (`code`)
) ENGINE=MyISAM;

CREATE TABLE `pw_house_developer` (
  `id` mediumint(8) NOT NULL AUTO_INCREMENT,
  `name` varchar(80) NOT NULL,
  `level` varchar(120) NOT NULL,
  `address` varchar(120) NOT NULL,
  `zipcode` varchar(6) NOT NULL,
  `email` varchar(60) NOT NULL,
  `url` varchar(120) NOT NULL,
  `principal` varchar(20) NOT NULL,
  `linkman` varchar(20) NOT NULL,
  `tel` varchar(30) NOT NULL,
  `fax` varchar(30) NOT NULL,
  `introduction` text NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM;

CREATE TABLE `pw_house_evaluations` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `uid` mediumint(8) unsigned NOT NULL,
  `username` varchar(50) NOT NULL DEFAULT '',
  `hid` mediumint(8) unsigned NOT NULL,
  `hname` varchar(50) NOT NULL,
  `ctime` int(10) unsigned NOT NULL,
  `ctype` enum('evaluation','score') NOT NULL DEFAULT 'evaluation',
  `content` text NOT NULL,
  `total` text NOT NULL,
  `ifcheck` tinyint(1) NOT NULL DEFAULT '0' COMMENT '0:ûͨ 1:ͨ',
  PRIMARY KEY (`id`),
  KEY `hid` (`hid`),
  KEY `uid` (`uid`),
  KEY `hname` (`hname`)
) ENGINE=MyISAM;

CREATE TABLE `pw_house_feed` (
  `id` mediumint(8) NOT NULL AUTO_INCREMENT,
  `hid` mediumint(8) NOT NULL,
  `postdate` int(10) unsigned NOT NULL,
  `descrip` text NOT NULL,
  `adddate` int(10) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `hid` (`hid`)
) ENGINE=MyISAM;

CREATE TABLE `pw_house_fields` (
  `id` smallint(6) unsigned NOT NULL AUTO_INCREMENT,
  `type` varchar(20) NOT NULL,
  `fieldvalue` varchar(80) NOT NULL,
  `vieworder` smallint(6) NOT NULL,
  `ifopen` tinyint(1) NOT NULL,
  PRIMARY KEY (`type`,`id`)
) ENGINE=MyISAM;

CREATE TABLE `pw_house_groupbuy` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `uid` mediumint(8) unsigned NOT NULL DEFAULT '0' COMMENT 'δע ο',
  `author` varchar(40) NOT NULL DEFAULT 'ο' COMMENT '̳û',
  `hid` mediumint(8) unsigned NOT NULL,
  `hname` varchar(40) NOT NULL DEFAULT '',
  `username` varchar(40) NOT NULL DEFAULT '' COMMENT 'ʵ',
  `gender` tinyint(2) NOT NULL DEFAULT '0' COMMENT '0 1Ů',
  `phone` varchar(20) NOT NULL DEFAULT '',
  `mobel` varchar(20) NOT NULL DEFAULT '',
  `qq` varchar(30) NOT NULL DEFAULT '',
  `msn` varchar(60) NOT NULL DEFAULT '',
  `email` varchar(60) NOT NULL DEFAULT '',
  `budget` smallint(6) unsigned NOT NULL DEFAULT '0',
  `area` smallint(6) unsigned NOT NULL DEFAULT '0',
  `ctime` int(10) unsigned NOT NULL,
  `remark` text NOT NULL,
  PRIMARY KEY (`id`),
  KEY `hname` (`hname`),
  KEY `budget` (`budget`),
  KEY `area` (`area`),
  KEY `ctime` (`ctime`)
) ENGINE=MyISAM;

CREATE TABLE `pw_house_image` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `typeid` smallint(6) unsigned NOT NULL,
  `hid` int(10) unsigned NOT NULL,
  `size` int(10) unsigned NOT NULL,
  `path` varchar(80) NOT NULL,
  `uploadtime` int(10) NOT NULL,
  `descrip` varchar(255) NOT NULL,
  `creator` varchar(20) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `typeid` (`typeid`),
  KEY `hid` (`hid`,`typeid`)
) ENGINE=MyISAM;

CREATE TABLE `pw_house_imagedata` (
  `imageid` int(10) unsigned NOT NULL,
  `hits` int(10) NOT NULL,
  PRIMARY KEY (`imageid`)
) ENGINE=MyISAM;

CREATE TABLE `pw_house_imagetype` (
  `id` smallint(6) unsigned NOT NULL AUTO_INCREMENT,
  `name` varchar(25) NOT NULL,
  `sub` smallint(6) unsigned NOT NULL DEFAULT '0',
  `position` smallint(6) unsigned NOT NULL DEFAULT '0',
  `ifuse` tinyint(1) unsigned NOT NULL DEFAULT '1',
  `ifsystem` tinyint(1) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  UNIQUE KEY `name` (`name`)
) ENGINE=MyISAM;

CREATE TABLE `pw_house_info` (
  `hid` mediumint(8) NOT NULL AUTO_INCREMENT,
  `name` varchar(40) NOT NULL,
  `ifopen` tinyint(1) unsigned NOT NULL,
  `recommend` tinyint(1) unsigned NOT NULL,
  `logo` varchar(80) NOT NULL,
  `banner` varchar(80) NOT NULL,
  `property` int(10) unsigned NOT NULL,
  `buildtype` int(10) unsigned NOT NULL,
  `area` mediumint(8) unsigned NOT NULL,
  `plate` mediumint(8) unsigned NOT NULL,
  `housetype` mediumint(8) unsigned NOT NULL,
  `address` varchar(120) NOT NULL,
  `saletele` varchar(30) NOT NULL,
  `saleaddress` varchar(120) NOT NULL,
  `developer` mediumint(8) unsigned NOT NULL,
  `aveprice` mediumint(8) unsigned NOT NULL,
  `status` mediumint(8) unsigned NOT NULL,
  `sellinglicense` varchar(120) NOT NULL,
  `paystatus` tinyint(10) unsigned NOT NULL,
  `opendate` int(10) NOT NULL,
  `deliverdate` int(10) NOT NULL,
  `buildingarea` mediumint(8) unsigned NOT NULL,
  `floorspace` mediumint(8) unsigned NOT NULL,
  `plotratio` decimal(5,2) NOT NULL,
  `greenratio` decimal(5,2) NOT NULL,
  `carport` smallint(6) unsigned NOT NULL,
  `carportfee` decimal(8,2) unsigned NOT NULL,
  `cleaningfee` decimal(8,2) NOT NULL,
  `adddate` int(10) NOT NULL,
  `postnum` int(10) unsigned NOT NULL,
  `groupbuynum` int(10) unsigned NOT NULL,
  `collectnum` int(10) unsigned NOT NULL,
  `hits` int(10) unsigned NOT NULL,
  `score` smallint(6) unsigned NOT NULL,
  `cyid` mediumint(8) unsigned NOT NULL,
  `tags` varchar(255) NOT NULL,
  PRIMARY KEY (`hid`),
  KEY `area` (`area`),
  KEY `aveprice` (`aveprice`)
) ENGINE=MyISAM;

CREATE TABLE `pw_house_infoextra` (
  `hid` mediumint(8) unsigned NOT NULL,
  `traffic` varchar(255) NOT NULL,
  `propertycompany` varchar(80) NOT NULL,
  `peripheral` text NOT NULL,
  `introduction` text NOT NULL,
  `nav` text NOT NULL,
  `seotitle` varchar(80) NOT NULL,
  `seokeywords` varchar(250) NOT NULL,
  `seodescription` text NOT NULL,
  PRIMARY KEY (`hid`)
) ENGINE=MyISAM;

CREATE TABLE `pw_house_map` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `hid` mediumint(8) unsigned NOT NULL,
  `x` varchar(20) DEFAULT '0',
  `y` varchar(20) DEFAULT '0',
  `zoom` smallint(2) NOT NULL COMMENT ' 3 - 17',
  `laber` text,
  PRIMARY KEY (`id`),
  UNIQUE KEY `hid` (`hid`),
  KEY `x` (`hid`,`x`,`y`)
) ENGINE=MyISAM;

CREATE TABLE `pw_house_pagecache` (
  `sign` char(32) NOT NULL,
  `type` varchar(30) NOT NULL,
  `data` text NOT NULL,
  `cachetime` int(10) unsigned NOT NULL,
  PRIMARY KEY (`sign`),
  KEY `type` (`type`)
) ENGINE=MyISAM;

CREATE TABLE `pw_house_pricedetail` (
  `id` smallint(8) unsigned NOT NULL AUTO_INCREMENT,
  `hid` smallint(8) unsigned NOT NULL,
  `title` varchar(30) NOT NULL DEFAULT '',
  `propertyid` smallint(6) unsigned NOT NULL,
  `buildtypeid` smallint(6) unsigned NOT NULL,
  `paystatusid` smallint(6) unsigned NOT NULL,
  `currentprice` varchar(10) NOT NULL,
  `opentime` int(11) unsigned NOT NULL,
  `paytime` int(11) unsigned NOT NULL,
  `hnum` smallint(6) unsigned NOT NULL,
  PRIMARY KEY (`id`),
  KEY `hid` (`hid`)
) ENGINE=MyISAM;

CREATE TABLE `pw_house_pushdata` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `hid` mediumint(8) unsigned NOT NULL,
  `model` varchar(30) NOT NULL,
  `title` varchar(255) NOT NULL,
  `titlecss` varchar(255) NOT NULL,
  `url` varchar(100) NOT NULL,
  `image` varchar(100) NOT NULL,
  `data` text NOT NULL,
  `offset` smallint(6) NOT NULL,
  `author` varchar(20) NOT NULL,
  `pushtime` int(10) NOT NULL,
  `iffailure` tinyint(1) unsigned NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`),
  KEY `hid` (`hid`,`model`),
  KEY `iffailure` (`iffailure`),
  KEY `iffailure_2` (`iffailure`)
) ENGINE=MyISAM;

CREATE TABLE `pw_house_recommend` (
  `hid` mediumint(8) unsigned NOT NULL,
  `timestamp` int(10) unsigned NOT NULL,
  PRIMARY KEY (`hid`)
) ENGINE=MyISAM;


CREATE TABLE `pw_house_userscore` (
  `hid` mediumint(8) unsigned NOT NULL,
  `uid` mediumint(8) unsigned NOT NULL,
  `stime` int(10) unsigned NOT NULL,
  `content` text NOT NULL,
  PRIMARY KEY (`hid`,`uid`)
) ENGINE=MyISAM;

CREATE TABLE `pw_house_video` (
  `id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT,
  `hid` mediumint(8) unsigned NOT NULL,
  `address` text NOT NULL,
  `image` varchar(255) NOT NULL,
  `uploadtime` int(10) NOT NULL,
  `descrip` varchar(255) NOT NULL,
  `ifembed` tinyint(1) NOT NULL,
  `creator` varchar(25) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `hid` (`hid`)
) ENGINE=MyISAM;

CREATE TABLE `pw_house_vrange` (
  `id` smallint(6) NOT NULL AUTO_INCREMENT,
  `type` varchar(20) NOT NULL,
  `fieldvalue` varchar(80) NOT NULL,
  `vstart` mediumint(8) NOT NULL,
  `vend` mediumint(8) NOT NULL,
  `vieworder` smallint(6) NOT NULL,
  `ifopen` tinyint(1) NOT NULL,
  PRIMARY KEY (`type`,`id`)
) ENGINE=MyISAM;

INSERT INTO `pw_house_imagetype` (`id`, `name`, `sub`, `position`, `ifuse`, `ifsystem`) VALUES
(1, 'ͼ', 0, 0, 1, 1),
(2, '', 0, 0, 1, 1),
(3, 'ʵͼ', 0, 0, 1, 1),
(4, '滮ͼ', 0, 0, 1, 1),
(5, 'һ', 1, 1, 1, 0),
(6, '', 1, 2, 1, 0),
(7, '', 1, 3, 1, 0),
(8, '', 1, 4, 1, 0),
(9, 'ʽ', 1, 5, 1, 0),
(10, 'ɳͼ', 0, 1, 1, 0);

REPLACE `pw_house_fields` (`id`, `type`, `fieldvalue`, `vieworder`, `ifopen`) VALUES
(1, 'property', '', 6, 1),
(2, 'property', 'ͨסլ', 1, 1),
(3, 'property', 'Ԣ', 2, 1),
(4, 'property', '԰ʽ', 3, 1),
(5, 'property', 'ƵʽԢ', 4, 1),
(6, 'property', 'ס', 5, 1),
(7, 'property', 'д¥', 7, 1),
(8, 'property', '', 8, 1),
(1, 'buildtype', 'Ͳ', 1, 1),
(2, 'buildtype', '', 2, 1),
(3, 'buildtype', 'С߲', 3, 1),
(4, 'buildtype', '߲', 4, 1),
(5, 'buildtype', '߲', 5, 1),
(1, 'paystatus', 'װ', 0, 1),
(2, 'paystatus', 'ë', 4, 1),
(3, 'paystatus', 'װ', 1, 1),
(1, 'housetype', 'ѧ', 0, 1),
(2, 'housetype', '', 2, 1),
(3, 'housetype', '', 3, 1),
(4, 'housetype', '', 4, 1),
(5, 'housetype', '»鷿', 5, 1),
(6, 'housetype', 'Ϸ', 6, 1),
(1, 'propertyright', '÷', 4, 1),
(2, 'propertyright', 'Ʒ', 2, 1),
(3, 'propertyright', 'ʹȨ', 3, 1),
(4, 'propertyright', '˲Ȩ', 1, 1),
(5, 'propertyright', '˾Ȩ', 5, 1),
(1, 'amenities', 'ˮ', 1, 1),
(2, 'amenities', '', 2, 1),
(3, 'amenities', 'ú/Ȼ', 3, 1),
(4, 'amenities', 'ů', 4, 1),
(5, 'amenities', 'ߵ', 5, 1),
(6, 'amenities', '', 6, 1),
(7, 'amenities', 'Ҿ', 7, 1),
(8, 'amenities', 'λ/', 8, 1),
(9, 'amenities', '', 9, 1),
(1, 'score', 'ͨ', 1, 1),
(2, 'score', '', 2, 1),
(3, 'score', '滮', 3, 1),
(4, 'score', '', 4, 1),
(5, 'score', '', 5, 1);

REPLACE `pw_house_vrange` (`id`, `type`, `fieldvalue`, `vstart`, `vend`, `vieworder`, `ifopen`) VALUES
(1, 'aveprice', '3000', 0, 3000, 0, 1),
(2, 'aveprice', '3000-5000', 3000, 5000, 1, 1),
(3, 'aveprice', '5000-7000', 5000, 7000, 2, 1),
(4, 'aveprice', '7000-10000', 7000, 10000, 3, 1),
(5, 'aveprice', '10000-13000', 10000, 13000, 4, 1),
(6, 'aveprice', '13000-16000', 13000, 16000, 5, 1),
(7, 'aveprice', '16000-20000', 16000, 20000, 6, 1),
(8, 'aveprice', '20000-25000', 20000, 25000, 7, 1),
(9, 'aveprice', '25000', 25000, 0, 8, 1),
(1, 'budget', '30', 0, 300000, 0, 1),
(2, 'budget', '30-40', 300000, 400000, 1, 1),
(3, 'budget', '40-50', 400000, 500000, 2, 1),
(4, 'budget', '50-60', 500000, 600000, 3, 1),
(5, 'budget', '60-80', 600000, 800000, 4, 1),
(6, 'budget', '80', 800000, 0, 5, 1),
(1, 'acreage', '50ƽ', 0, 50, 0, 1),
(2, 'acreage', '50-70ƽ', 50, 70, 1, 1),
(3, 'acreage', '70-100ƽ', 70, 100, 2, 1),
(4, 'acreage', '100-150ƽ', 100, 150, 3, 1),
(5, 'acreage', '150-200ƽ', 150, 200, 4, 1),
(6, 'acreage', '200ƽ', 200, 0, 5, 1),
(1, 'rentprice', '500Ԫ', 0, 500, 0, 1),
(2, 'rentprice', '500-1000Ԫ', 500, 1000, 1, 1),
(3, 'rentprice', '1000-1500Ԫ', 1000, 1500, 2, 1),
(4, 'rentprice', '1500-2000Ԫ', 1500, 2000, 3, 1),
(5, 'rentprice', '2000Ԫ', 2000, 0, 4, 1),
(1, 'sellprice', '50', 0, 50, 0, 1),
(2, 'sellprice', '50-100', 50, 100, 1, 1),
(3, 'sellprice', '100', 100, 0, 2, 1);

DELETE FROM `pw_nav` WHERE `type` = 'house_navinfo';
INSERT INTO `pw_nav` (`nkey`, `type`, `title`, `style`, `link`, `alt`, `pos`, `target`, `view`, `upid`, `isshow`) VALUES
('', 'house_navinfo', '¥̴ȫ', '|||', 'mode.php?m=house&q=list', '', '-1', 0, 2, 0, 1),
('', 'house_navinfo', 'ͼҷ', '|||', 'mode.php?m=house&q=housemap&hid=20&step=searchinfo', '', '-1', 0, 3, 0, 1),
('', 'house_navinfo', '¥Ѷ', '|||', '#', '', '-1', 1, 0, 0, 1),
('', 'house_navinfo', 'סլ', '|||', 'mode.php?m=house&q=list&property=2', '', '-1', 0, 0, 0, 1),
('', 'house_navinfo', '', '|||', 'mode.php?m=house&q=list&property=1', '', '-1', 0, 0, 0, 1),
('', 'house_navinfo', 'д¥', '|||', 'mode.php?m=house&q=list&property=7', '', '-1', 0, 0, 1, 1),
('', 'house_navinfo', '', '|||', 'mode.php?m=house&q=list&property=8', '', '-1', 0, 0, 0, 1),
('', 'house_navinfo', 'ҵС', '|||', '', '', '-1', 1, 0, 0, 1);

ALTER TABLE  `pw_house_info` ADD  `isdimopendate` TINYINT( 3 ) NOT NULL DEFAULT  '0' AFTER  `deliverdate` ;
ALTER TABLE  `pw_house_info` ADD  `isdimdeliverdate` TINYINT( 3 ) NOT NULL DEFAULT  '0' AFTER  `isdimopendate` ;
ALTER TABLE `pw_house_fields` ADD `parent` SMALLINT NOT NULL DEFAULT '0';
REPLACE INTO `pw_house_brokergroup` (`groupid`, `name`, `usernum`) VALUES
(1, 'ͨ', 0),
(2, 'VIP', 0);

REPLACE INTO `pw_house_brokerright` (`groupid`, `rightkey`, `rightvalue`) VALUES
(1, 'ifsale', '1'),
(1, 'salenum', '10'),
(1, 'ifhire', '1'),
(1, 'hirenum', '50'),
(2, 'ifsale', '1'),
(2, 'salenum', '10'),
(2, 'ifhire', '1'),
(2, 'hirenum', '50');

DELETE FROM pw_advert WHERE `type` =0 AND ckey like'%House%';
INSERT INTO `pw_advert` (`type`, `uid`, `ckey`, `stime`, `etime`, `ifshow`, `orderby`, `descrip`, `config`) VALUES
(0, 0, 'Mode.House.Index.Center4', 0, 0, 1, 0, '·ҳмλ4', 'a:1:{s:7:\"display\";s:3:\"all\";}'),
(0, 0, 'Mode.House.Index.Center3', 0, 0, 1, 0, '·ҳмλ3', 'a:1:{s:7:\"display\";s:3:\"all\";}'),
(0, 0, 'Mode.House.Index.Center2', 0, 0, 1, 0, '·ҳмλ2', 'a:1:{s:7:\"display\";s:3:\"all\";}'),
(0, 0, 'Mode.House.Index.Center1', 0, 0, 1, 0, '·ҳмλ1', 'a:1:{s:7:\"display\";s:3:\"all\";}'),
(0, 0, 'Mode.House.Index.Right4', 0, 0, 1, 0, '·ҳ4', 'a:1:{s:7:\"display\";s:3:\"all\";}'),
(0, 0, 'Mode.House.Index.Right3', 0, 0, 1, 0, '·ҳ3', 'a:1:{s:7:\"display\";s:3:\"all\";}'),
(0, 0, 'Mode.House.Index.Right2', 0, 0, 1, 0, '·ҳ2', 'a:1:{s:7:\"display\";s:3:\"all\";}'),
(0, 0, 'Mode.House.Index.Right1', 0, 0, 1, 0, '·ҳ1', 'a:1:{s:7:\"display\";s:3:\"all\";}'),
(0, 0, 'Mode.House.Info.Footer', 0, 0, 1, 0, '·չʾҳײ', 'a:1:{s:7:\"display\";s:4:\"rand\";}'),
(0, 0, 'Mode.House.Info.Center', 0, 0, 1, 0, '·չʾҳм', 'a:1:{s:7:\"display\";s:4:\"rand\";}'),
(0, 0, 'Mode.House.List.Rigtht', 0, 0, 1, 0, '·бҳ', 'a:1:{s:7:\"display\";s:4:\"rand\";}'),
(0, 0, 'Mode.House.Index.Header', 0, 0, 1, 0, '·ҳͷ', 'a:1:{s:7:\"display\";s:3:\"all\";}'),
(0, 0, 'Mode.House.Index.Right', 0, 0, 1, 0, '·ҳ', 'a:1:{s:7:\"display\";s:3:\"all\";}'),
(0, 0, 'Mode.House.Index.Center', 0, 0, 1, 0, '·ҳмλ', 'a:1:{s:7:\"display\";s:4:\"rand\";}'),
(0, 0, 'Mode.House.Index.Footer', 0, 0, 1, 0, '·ҳײ', 'a:1:{s:7:\"display\";s:3:\"all\";}'),
(0, 0, 'Mode.House.List.Footer', 0, 0, 1, 0, '·бҳײ', 'a:1:{s:7:\"display\";s:4:\"rand\";}'),
(0, 0, 'Mode.House.Info.Right', 0, 0, 1, 0, '·չʾҳ', 'a:1:{s:7:\"display\";s:4:\"rand\";}'),
(0, 0, 'Mode.House.Info.Header', 0, 0, 1, 0, '·չʾҳͷ', 'a:1:{s:7:\"display\";s:4:\"rand\";}'),
(0, 0, 'Mode.House.List.Header', 0, 0, 1, 0, '·бҳͷ', 'a:1:{s:7:\"display\";s:4:\"rand\";}'),
('0','0','Mode.House.Sale.Footer','0','0','1','0','ַбҳײ','a:1:{s:7:\"display\";s:4:\"rand\";}'),
('0','0','Mode.House.Sale.Left','0','0','1','0','ַбҳҲλ','a:1:{s:7:\"display\";s:4:\"rand\";}'),
('0','0','Mode.House.Hire.Footer','0','0','1','0','ⷿбҳײ','a:1:{s:7:\"display\";s:4:\"rand\";}'),
('0','0','Mode.House.Hire.Left','0','0','1','0','ⷿбҳҲλ','a:1:{s:7:\"display\";s:4:\"rand\";}'),
('0','0','Mode.House.Second.Center','0','0','1','0','ַҳмλ','a:1:{s:7:\"display\";s:4:\"rand\";}'),
('0','0','Mode.House.Second.Left','0','0','1','0','ַҳҲλ','a:1:{s:7:\"display\";s:4:\"rand\";}');

ALTER TABLE `pw_house_hireinfo` CHANGE `price` `price` DECIMAL( 10, 2 ) NOT NULL DEFAULT '0';
ALTER TABLE `pw_house_saleinfo` CHANGE `price` `price` DECIMAL( 10, 2 ) NOT NULL DEFAULT '0';
ALTER TABLE `pw_house_saleoverdue` CHANGE `price` `price` DECIMAL( 10, 2 ) NOT NULL DEFAULT '0';

ALTER TABLE pw_house_area ADD COLUMN `ord`  smallint(6) NOT NULL DEFAULT 0;

ALTER TABLE pw_house_saleinfo ADD COLUMN `remark` VARCHAR(255) NOT NULL DEFAULT '';

ALTER TABLE pw_house_hireinfo ADD COLUMN `remark` VARCHAR(255) NOT NULL DEFAULT '';
ALTER TABLE `pw_house_broker` add `agencyid` INT( 10 ) NOT NULL DEFAULT '0';
DROP TABLE IF EXISTS `pw_house_agency`;
CREATE TABLE `pw_house_agency` (
  `agencyid` int(10) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL DEFAULT '',
  `address` varchar(255) NOT NULL DEFAULT '',
  `icon` varchar(255) NOT NULL DEFAULT '',
  `bgimg` varchar(255) NOT NULL DEFAULT '',
  `mainbusiness` tinyint(3) NOT NULL DEFAULT '0',
  `adminname` varchar(30) NOT NULL DEFAULT '',
  `isopen` tinyint(3) NOT NULL DEFAULT '0',
  `vieworder` tinyint(3) NOT NULL DEFAULT '0',
  KEY `idx_agencyid` (`agencyid`)
) ENGINE=MyISAM;

ALTER TABLE `pw_house_broker` add `ifcompany` tinyint( 3 ) NOT NULL DEFAULT '0';
ALTER TABLE `pw_house_broker` add index `idx_agencyid_ifactive_ifcompany` (`agencyid`, `ifactive`, `ifcompany`);