/*****11-15*****/
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_hireinfo` ADD `areatype` TINYINT( 3 ) NOT NULL DEFAULT '0' AFTER `houseid` ,
ADD `platetype` TINYINT( 3 ) NOT NULL DEFAULT '0' AFTER `areatype` ,
ADD `pricetype` TINYINT( 3 ) NOT NULL DEFAULT '0' AFTER `platetype` ,
ADD `housetype` TINYINT( 3 ) NOT NULL DEFAULT '0' AFTER `pricetype` ,
ADD `roomtype` TINYINT( 3 ) NOT NULL DEFAULT '0' AFTER `housetype` ,
ADD `hiretype` TINYINT( 3 ) NOT NULL DEFAULT '0' AFTER `roomtype` ;

ALTER TABLE `pw_house_saleinfo` ADD `areatype` TINYINT( 3 ) NOT NULL DEFAULT '0' AFTER `houseid`,
ADD `platetype` TINYINT( 3 ) NOT NULL DEFAULT '0' AFTER `areatype`,
ADD `pricetype` TINYINT( 3 ) NOT NULL DEFAULT '0' AFTER `platetype`,
ADD `acreagetype` TINYINT( 3 ) NOT NULL DEFAULT '0' AFTER `pricetype`,
ADD `roomtype` TINYINT( 3 ) NOT NULL DEFAULT '0' AFTER `acreagetype`,
ADD `housetype` TINYINT( 3 ) NOT NULL DEFAULT '0' AFTER `roomtype`;
/*2010-09-27*/
 ALTER TABLE `pw_house_broker` CHANGE `plate` `plate` TEXT CHARACTER SET gbk COLLATE gbk_chinese_ci NOT NULL  
 
ALTER TABLE  `pw_house_saleinfo` CHANGE  `acreage`  `acreage` FLOAT( 10 ) NOT NULL DEFAULT  '0';
ALTER TABLE  `pw_house_hireinfo` CHANGE  `acreage`  `acreage` FLOAT( 10 ) NOT NULL DEFAULT  '0';
/*add by suqian 2010-09-20*/
ALTER TABLE `pw_house_report` CHANGE `url` `id` INT( 10 ) NOT NULL DEFAULT '0' 

/*add by liaohu 2010-09-20*/
ALTER TABLE  `pw_house_info` ADD  `isdimopendate` TINYINT( 3 ) NOT NULL DEFAULT  '0' AFTER  `deliverdate` ,
ADD  `isdimdeliverdate` TINYINT( 3 ) NOT NULL DEFAULT  '0' AFTER  `isdimopendate` ;
/*add by liaohu 2010-09-19*/
ALTER TABLE  `pw_house_hireinfo` DROP  `plate`;
ALTER TABLE  `pw_house_hiremodifytime_index` ADD  `platetype` TINYINT( 3 ) NOT NULL DEFAULT  '0' AFTER  `areatype` ;
ALTER TABLE  `pw_house_hireposttime_index` ADD  `platetype` TINYINT( 3 ) NOT NULL DEFAULT  '0' AFTER  `areatype` ;
ALTER TABLE  `pw_house_hireprice_index` ADD  `platetype` TINYINT( 3 ) NOT NULL DEFAULT  '0' AFTER  `areatype` ;
ALTER TABLE  `pw_house_hireoverdue` ADD  `platetype` TINYINT( 3 ) NOT NULL DEFAULT  '0' AFTER  `areatype` ;

ALTER TABLE  `pw_house_saleinfo` DROP  `plate`;
ALTER TABLE  `pw_house_salemodifytime_index` ADD  `platetype` TINYINT( 3 ) NOT NULL DEFAULT  '0' AFTER  `areatype` ;
ALTER TABLE  `pw_house_saleposttime_index` ADD  `platetype` TINYINT( 3 ) NOT NULL DEFAULT  '0' AFTER  `areatype` ;
ALTER TABLE  `pw_house_saleprice_index` ADD  `platetype` TINYINT( 3 ) NOT NULL DEFAULT  '0' AFTER  `areatype` ;
ALTER TABLE  `pw_house_saleunitprice_index` ADD  `platetype` TINYINT( 3 ) NOT NULL DEFAULT  '0' AFTER  `areatype` ;
ALTER TABLE  `pw_house_saleoverdue` ADD  `platetype` TINYINT( 3 ) NOT NULL DEFAULT  '0' AFTER  `areatype` ;

ALTER TABLE `pw_house_fields` ADD `parent` SMALLINT NOT NULL DEFAULT '0';
ALTER TABLE `pw_house_broker` ADD `ifactive` TINYINT( 3 ) NOT NULL DEFAULT '1' AFTER `realname` ;
ALTER TABLE `pw_house_hireinfo` ADD `linkman` VARCHAR( 50 ) NOT NULL DEFAULT ' ' AFTER `gate`;
ALTER TABLE `pw_house_saleinfo` ADD `linkman` VARCHAR( 50 ) NOT NULL DEFAULT ' ' AFTER `gate`;
DROP TABLE IF EXISTS `pw_house_expired`;
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;

ALTER TABLE `pw_house_hireinfo`  ADD INDEX `idx_price` ( `price` ); 
ALTER TABLE `pw_house_saleinfo`
ADD INDEX `idx_price` ( `price` ),
ADD INDEX `idx_unitprice` ( `unitprice` );

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);

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', '经济适用房', 1, 1),
(2, 'propertyright', '商品房', 2, 1),
(3, 'propertyright', '使用权', 3, 1),
(4, 'propertyright', '个人产权', 4, 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);

REPLACE into pw_advert (type, uid, ckey, stime, etime, ifshow, orderby, descrip, config) values
('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\";}');

/*
*小狼 2010-09-09
*/
ALTER TABLE `pw_house_broker`
  DROP `salenum`,
  DROP `hirenum`,
  DROP `todaysalenum`,
  DROP `lastsaletime`,
  DROP `todayhirenum`,
  DROP `lasthiretime`;
/*
@TableName: 二手房发布数量信息表
@Fields `uid`		用户id
@Fields `salenum`	出售房数量
@Fields `hirenum`	出租房数量
@Fields `todaysalenum`	当日出售房数量
@Fields `lastsaletime`	最后发出售房时间
@Fields `todayhirenum`  当日出租房数量
@Fields `lasthiretime`  最后发出租房实际那
@Fields `ifbroker`	是否是经济人
*/
CREATE TABLE `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;


#2010-09-02 小狼
/*
@TableName:过期数据表
@Fields `id`		自增ID
@Fields `datatype`	'数据类型'
@Fields `expiredtype`	'过期类型'
@Fields `houseid`	'房源id'
@Fields `expiredtime`   '过期时间'
*/
CREATE TABLE `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 ;
/*
@TableName:出售房信息表
@Fields `houseid` 房源ID
@Fields `subject` 用户名
@Fields `uid` 用户ID
@Fields `username`  '用户名'
@Fields `istop`  '是否置顶-0 为不置顶'
@Fields `isurgent`  '是否加急:0表示不加急'
@Fields `isbroker` '是否是经济人'
@Fields `acreage` '总面积'
@Fields `currentfloor` '当前楼层'
@Fields `totalfloor` '总楼层'
@Fields `price`  '总售价'
@Fields `unitprice` '单位面积价格'
@Fields `room`  '户型：室/厅/卫/阳台'
@Fields `righter` '房屋产权'
@Fields `village` '小区名'
@Fields `plate` '板块'
@Fields `address` '具体地址'
@Fields `buildtime` '建筑年代'
@Fields `traffic` '交通情况'
@Fields `fitment` '装修程度'
@Fields `equipment` '配套设施'
@Fields  `thumb` '缩略图'
@Fields  `state` '状态'
@Fields `descrip` '房源描述'
@Fields `gate`  '组合信息供搜索用'
@Fields `posttime`  '发布时间'
@Fields `modifytime`  '修改时间'
*/
DROP TABLE IF EXISTS pw_house_saleinfo;
CREATE TABLE IF NOT EXISTS `pw_house_saleinfo` (
  `houseid` int(8) NOT NULL AUTO_INCREMENT,
  `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` int(10) 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 ' ',
  `plate` tinyint(3) NOT NULL DEFAULT '0',
  `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,
  `gate` varchar(200) 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`)
) ENGINE=MyISAM;
/*
@TableName:修改时间索引表
@Fields `houseid` 房源ID
@Fields `areatype`  '区域'
@Fields `pricetype`  '价格区间'
@Fields `acreagetype` '面积区间'
@Fields `roomtype`   '物业类型'
@Fields `housetype` '房型'
@Fields `modifytime`  '修改时间'
*/
DROP TABLE IF EXISTS pw_house_salemodifytime;
DROP TABLE IF EXISTS pw_house_salemodifytime_index;
CREATE TABLE IF NOT EXISTS `pw_house_salemodifytime_index` (
  `houseid` int(8) NOT NULL,
  `areatype` 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_area_price_acreage_room_house_modifytime` (`areatype`,`pricetype`,`acreagetype`,`roomtype`,`housetype`,`modifytime`),
  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`)
) ENGINE=MyISAM;
/*
@TableName:过期信息表
@Fields `houseid` 房源ID
@Fields `areatype`  '区域'
@Fields `pricetype`  '价格区间'
@Fields `acreagetype` '面积区间'
@Fields `roomtype`   '物业类型'
@Fields `housetype` '房型'
@Fields `modifytime`  '修改时间'
@Fields `posttime`  '发布时间'
@Fields `price`  '价格'
@Fields `unitprice`  '单价'
*/
DROP TABLE IF EXISTS pw_house_saleoverdue;
CREATE TABLE IF NOT EXISTS `pw_house_saleoverdue` (
  `houseid` int(8) NOT NULL DEFAULT '0',
  `areatype` 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;
/*
@TableName:修改时间索引表
@Fields `houseid` 房源ID
@Fields `areatype`  '区域'
@Fields `pricetype`  '价格区间'
@Fields `acreagetype` '面积区间'
@Fields `roomtype`   '物业类型'
@Fields `housetype` '房型'
@Fields `modifytime`  '发布时间'
*/
DROP TABLE IF EXISTS pw_house_saleposttime;
DROP TABLE IF EXISTS pw_house_saleposttime_index;
CREATE TABLE IF NOT EXISTS `pw_house_saleposttime_index` (
  `houseid` int(8) NOT NULL,
  `areatype` 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_area_price_acreage_room_house_posttime` (`areatype`,`pricetype`,`acreagetype`,`roomtype`,`housetype`,`posttime`),
  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`)
) ENGINE=MyISAM;
/*
@TableName:价格索引表
@Fields `houseid` 房源ID
@Fields `areatype`  '区域'
@Fields `pricetype`  '价格区间'
@Fields `acreagetype` '面积区间'
@Fields `roomtype`   '物业类型'
@Fields `housetype` '房型'
@Fields `modifytime`  '价格'
*/
DROP TABLE IF EXISTS pw_house_saleprice;
DROP TABLE IF EXISTS pw_house_saleprice_index;
CREATE TABLE IF NOT EXISTS `pw_house_saleprice_index` (
  `houseid` int(8) NOT NULL,
  `areatype` 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_area_price_acreage_room_house_price` (`areatype`,`pricetype`,`acreagetype`,`roomtype`,`housetype`,`price`),
  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`)
) ENGINE=MyISAM;
/*
@TableName:单价索引表
@Fields `houseid` 房源ID
@Fields `areatype`  '区域'
@Fields `pricetype`  '价格区间'
@Fields `acreagetype` '面积区间'
@Fields `roomtype`   '物业类型'
@Fields `housetype` '房型'
@Fields `modifytime`  '单价'
*/
DROP TABLE IF EXISTS pw_house_saleunitprice;
DROP TABLE IF EXISTS pw_house_saleunitprice_index;
CREATE TABLE IF NOT EXISTS `pw_house_saleunitprice_index` (
  `houseid` int(8) NOT NULL,
  `areatype` 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_area_price_acreage_room_house_unitprice` (`areatype`,`pricetype`,`acreagetype`,`roomtype`,`housetype`,`unitprice`),
  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`)
) ENGINE=MyISAM;
/*
@TableName:出售房信息表
@Fields `houseid` 房源ID
@Fields `subject` 用户名
@Fields `uid` 用户ID
@Fields `username`  '用户名'
@Fields `ischarge`  '是否收费
@Fields `istop`  '是否置顶-0 为不置顶'
@Fields `isurgent`  '是否加急:0表示不加急'
@Fields `isbroker` '是否是经济人'
@Fields `acreage` '总面积'
@Fields `currentfloor` '当前楼层'
@Fields `totalfloor` '总楼层'
@Fields `price`  '总售价'
@Fields `room`  '户型：室/厅/卫/阳台'
@Fields `village` '小区名'
@Fields `plate` '板块'
@Fields `address` '具体地址'
@Fields `buildtime` '建筑年代'
@Fields `traffic` '交通情况'
@Fields `fitment` '装修程度'
@Fields `equipment` '配套设施'
@Fields  `thumb` '缩略图'
@Fields  `state` '状态'
@Fields `descrip` '房源描述'
@Fields `gate`  '组合信息供搜索用'
@Fields `posttime`  '发布时间'
@Fields `modifytime`  '修改时间'
*/
DROP TABLE IF EXISTS pw_house_hireinfo;
CREATE TABLE IF NOT EXISTS `pw_house_hireinfo` (
  `houseid` int(8) NOT NULL AUTO_INCREMENT,
  `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` int(10) 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 ' ',
  `plate` tinyint(3) NOT NULL DEFAULT '0',
  `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 ' ',
  `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`)
) ENGINE=MyISAM;
/*
@TableName:修改时间索引表
@Fields `houseid` 房源ID
@Fields `areatype`  '区域'
@Fields `pricetype`  '价格区间'
@Fields `acreagetype` '面积区间'
@Fields `roomtype`   '物业类型'
@Fields `housetype` '房型'
@Fields `modifytime`  '修改时间'
*/
DROP TABLE IF EXISTS pw_house_hiremodifytime;
DROP TABLE IF EXISTS pw_house_hiremodifytime_index;
CREATE TABLE IF NOT EXISTS `pw_house_hiremodifytime_index` (
  `houseid` int(8) NOT NULL,
  `areatype` 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_area_price_house_room_hire_modifytime` (`areatype`,`pricetype`,`housetype`,`roomtype`,`hiretype`,`modifytime`),
  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`)
) ENGINE=MyISAM;
/*
@TableName:过期信息表
@Fields `houseid` 房源ID
@Fields `areatype`  '区域'
@Fields `pricetype`  '价格区间'
@Fields `acreagetype` '面积区间'
@Fields `roomtype`   '物业类型'
@Fields `housetype` '房型'
@Fields `modifytime`  '修改时间'
@Fields `price`  '价格'
*/
DROP TABLE IF EXISTS pw_house_hireoverdue;
CREATE TABLE IF NOT EXISTS `pw_house_hireoverdue` (
  `houseid` int(8) NOT NULL DEFAULT '0',
  `areatype` 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;
/*
@TableName:发布时间索引表
@Fields `houseid` 房源ID
@Fields `areatype`  '区域'
@Fields `pricetype`  '价格区间'
@Fields `acreagetype` '面积区间'
@Fields `roomtype`   '物业类型'
@Fields `housetype` '房型'
@Fields `posttime`  '发布时间'
*/
DROP TABLE IF EXISTS pw_house_hireposttime;
DROP TABLE IF EXISTS pw_house_hireposttime_index;
CREATE TABLE IF NOT EXISTS `pw_house_hireposttime_index` (
  `houseid` int(8) NOT NULL,
  `areatype` 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_area_price_house_room_hire_posttime` (`areatype`,`pricetype`,`housetype`,`roomtype`,`hiretype`,`posttime`),
  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`)
) ENGINE=MyISAM;
/*
@TableName:价格索引表
@Fields `houseid` 房源ID
@Fields `areatype`  '区域'
@Fields `pricetype`  '价格区间'
@Fields `acreagetype` '面积区间'
@Fields `roomtype`   '物业类型'
@Fields `housetype` '房型'
@Fields `price`  '修改时间'
*/
DROP TABLE IF EXISTS pw_house_hireprice;
DROP TABLE IF EXISTS pw_house_hireprice_index;
CREATE TABLE IF NOT EXISTS `pw_house_hireprice_index` (
  `houseid` int(8) NOT NULL,
  `areatype` 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_area_price_house_room_hire_price` (`areatype`,`pricetype`,`housetype`,`roomtype`,`hiretype`,`price`),
  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`)
) ENGINE=MyISAM;
/*
@TableName:价格索引表
@Fields `houseid` 房源ID
@Fields `datatype` '数据类型'
@Fields `linkman` '联系人'
@Fields `phone` '手机'
@Fields `tel` '电话'
@Fields `email` 'email'
*/
DROP TABLE IF EXISTS pw_house_personal;
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;
/*
@TableName:二手房，租房相关图片表
@Created By 小狼@2010-8-23
@Fields imageid 	主键ID
@Fields type 		图片类型
@Fields houseid 	房子id
@Fields size 		图片大小
@Fields path 		图片路径
@Fields uploadtime 	上传时间
@Fields descrip 	图片描述
@Fields creator 	上传者
@Fields name	 	图片名称
@Modified By renbingbing@2010-9-3 增加name字段
*/
CREATE TABLE `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;
/*
@TableName:房产举报表 pw_house_report
@Created By renbingbing@2010-8-23
@Engine:MyISAM
@Primary Key:id
@Fields reportid 	主键ID
@Fields uid 		举报用户ID
@Fields username	举报用户名
@Fields reason 		举报原因
@Fields handle 		举报是否已经处理
@Fields type 		举报类型
@Fields url 		链接来源
@Fields time 		举报时间
*/
CREATE TABLE `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',
  `url` varchar(150) NOT NULL DEFAULT '',
  `time` int(10) NOT NULL DEFAULT '0',
  PRIMARY KEY (`reportid`)
) ENGINE=MyISAM;

/*
@TableName:二手房，经纪人用户组
@Created By 苏骞@2010-8-23
@Fields groupid 头衔ID
@Fields name 头衔名称
@Fields usernum 成员统计
*/
CREATE TABLE `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;


/*
@TableName:二手房，经纪人用户组权限
@Created By 郑勇@2010-8-23
@Fields groupid 用户组ID
@Fields rightkey 权限键值
@Fields rightvalue 权限值
*/
CREATE TABLE `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;

/*
@TableName:二手房，纪经人信息
@Created By 苏骞@2010-8-23
@Fields bid  经纪人ID
@Fields username 用户名
@Fields realname 姓名
@Fields area 主营区域
@Fields plate 主营板块
@Fields company 所属公司
@Fields address 工作地址
@Fields email 电子邮箱
@Fields tel 电话号码
@Fields phone 手机号码
@Fields verify 认证类型
@Fields idcard 身份证号码
@Fields idcardpic 身份证图片
@Fields alipay 支付宝账号
@Fields otherinfo 其他认证信息
@Fields remark 备注
@Fields createtime 加入时间
@Fields announce 店铺公告
@Fields business 主营业务
@Modified By renbingbing@2010-9-3  增加announce,business字段
*/
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 '',
  `area` int(10) NOT NULL DEFAULT '0',
  `plate` varchar(255) NOT NULL DEFAULT '',
  `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 DEFAULT '',
  `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;

--- 区域添加排序号 可以添加长度为5位
ALTER TABLE pw_house_area ADD COLUMN `ord`  smallint(6) NOT NULL DEFAULT 0;

--- pw_house_saleinfo 表中条件remark字段 ，提供经纪人可以输入备注信息
ALTER TABLE pw_house_saleinfo ADD COLUMN `remark` VARCHAR(255) NOT NULL DEFAULT '';

--- pw_house_hireinfo 表中条件remark字段 ，提供经纪人可以输入备注信息
ALTER TABLE pw_house_hireinfo ADD COLUMN `remark` VARCHAR(255) NOT NULL DEFAULT '';

/*
@TableName:中介公司表
@Fields agencyid  ID
@Fields name 公司名称
@Fields address 地址
@Fields icon 图标
@Fields bgimg 背景图片
@Fields mainbusiness 主营业务
@Fields administrator 管理员
@Fields vieworder 显示顺序
*/
CREATE TABLE IF NOT EXISTS `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',
  `salenum` int(10) NOT NULL DEFAULT '0',
  `hirenum` int(10) NOT NULL DEFAULT '0',
  `vieworder` tinyint(3) NOT NULL DEFAULT '0',
  KEY `idx_agencyid` (`agencyid`)
) ENGINE=MyISAM;

ALTER TABLE `pw_house_broker` add `agencyid` INT( 10 ) NOT NULL DEFAULT '0';