$addSql=" left join (select buildproperty_id,house_area,image_id,house_id as bph_id from ".Config::A_DISTRICT_AREA_TABLE.") ada on th.id = ada.bph_id".
if($array['houseType']==0){
" left join (select value as bp_value,literal as bp_literal from ".Config::DIC_BUILDPROPERTY_TABLE.") dbp on ada.buildproperty_id = dbp.bp_value";
$addSql=" left join (select buildproperty_id,house_area,image_id,house_id as bph_id from ".Config::A_DISTRICT_AREA_TABLE.") ada on th.id = ada.bph_id".
$orderbySql=" group by th.id order by th.creattime DESC";
" left join (select value as bp_value,literal as bp_literal from ".Config::DIC_BUILDPROPERTY_TABLE.") dbp on ada.buildproperty_id = dbp.bp_value";
}elseif($array['houseType']==1){
$orderbySql=" group by th.id order by th.creattime DESC";
$addSql=" left join (select value as bp_value,literal as bp_literal from ".Config::DIC_BUILDPROPERTY_TABLE.") dbp on if(th.buildproperty_id>5,5,buildproperty_id) = dbp.bp_value";
}elseif($array['houseType']==1){
if($array['feature']>-1){
$addSql=" left join (select value as bp_value,literal as bp_literal from ".Config::DIC_BUILDPROPERTY_TABLE.") dbp on th.buildproperty_id = dbp.bp_value";
$addSql.=" left join (select house_id,tag_id from ".Config::A_HOUSE_TAG_TABLE.") aht on th.id = aht.house_id";
if($array['feature']>-1){
$addWhereSql=" and tag_id = ".$array['feature'];
$addSql.=" left join (select house_id,tag_id from ".Config::A_HOUSE_TAG_TABLE.") aht on th.id = aht.house_id";
}
$addWhereSql=" and tag_id = ".$array['feature'];
$orderbySql=" order by th.creattime DESC";
}
}elseif($array['houseType']==2){
$orderbySql=" order by th.creattime DESC";
$addSql=" left join (select value as bp_value,literal as bp_literal from ".Config::DIC_BUILDPROPERTY_TABLE.") dbp on th.buildproperty_id = dbp.bp_value";
}elseif($array['houseType']==2){
$orderbySql=" order by th.creattime DESC";
$addSql=" left join (select value as bp_value,literal as bp_literal from ".Config::DIC_BUILDPROPERTY_TABLE.") dbp on th.buildproperty_id = dbp.bp_value";
"ti.path,dr.literal,th.house_number,dbp.bp_literal,th.owner_name,th.owner_phone,(SELECT GROUP_CONCAT(left(tt.name,3)) from ".Config::A_HOUSE_TAG_TABLE." aht".
" LEFT JOIN ".Config::TOSPUR_TAG_TABLE." tt on tt.id = aht.tag_id".
"ti.path,dr.literal,th.house_number,dbp.bp_literal,th.owner_name,th.owner_phone,(SELECT GROUP_CONCAT(left(tt.name,3)) from ".Config::A_HOUSE_TAG_TABLE." aht".
" where aht.house_id = th.id) as tags from ".Config::TOSPUR_HOUSE_TABLE." th".
" LEFT JOIN ".Config::TOSPUR_TAG_TABLE." tt on tt.id = aht.tag_id".
$addSql.
" where aht.house_id = th.id) as tags from ".Config::TOSPUR_HOUSE_TABLE." th".
" left join ".Config::DIC_CITY_TABLE." dc on th.plate_id = dc.plateId".
$addSql.
" left join (select id as rid,value as r_value,literal from ".Config::DIC_ROOM_TABLE.") dr on th.room_id = dr.r_value".
" left join ".Config::DIC_CITY_TABLE." dc on th.plate_id = dc.plateId".
" left join (select id as image_id,path from ".Config::TOSPUR_IMAGE_TABLE.") ti on ti.image_id = th.frontCover_id".
" left join (select id as rid,value as r_value,literal from ".Config::DIC_ROOM_TABLE.") dr on th.room_id = dr.r_value".
" where 1=1 and th.status = 1 ";
" left join (select id as image_id,path from ".Config::TOSPUR_IMAGE_TABLE.") ti on ti.image_id = th.frontCover_id".
if($array['cityId']>-1){
" where 1=1 and th.status = 1 ";
$params[]=$array['cityId'];
if($array['cityId']>-1){
$sql=$sql." and cityId=%d";
$params[]=$array['cityId'];
}
$sql=$sql." and cityId=%d";
if($array['districtId']>-1){
}
$params[]=$array['districtId'];
if($array['districtId']>-1){
$sql=$sql." and districtId=%d";
$params[]=$array['districtId'];
}
$sql=$sql." and districtId=%d";
if($array['plateId']>-1){
}
$params[]=$array['plateId'];
if($array['plateId']>-1){
$sql=$sql." and plateId=%d";
$params[]=$array['plateId'];
}
$sql=$sql." and plateId=%d";
if($array['buildPropertyId']>-1){
}
$params[]=$array['buildPropertyId'];
if($array['buildPropertyId']>-1){
if($array['houseType']==0){
$params[]=$array['buildPropertyId'];
$sql=$sql." and ada.buildproperty_id=%d";
if($array['houseType']==0){
}else{
$sql=$sql." and ada.buildproperty_id=%d";
$sql=$sql." and th.buildproperty_id=%d";
}else{
}
$sql=$sql." and th.buildproperty_id=%d";
}
}
if($array['roomId']>-1){
}
$params[]=$array['roomId'];
if($array['roomId']>-1){
$sql=$sql." and room_id=%d";
$params[]=$array['roomId'];
}
$sql=$sql." and room_id=%d";
if($array['acreage']>-1){
}
$areaArray=explode("-",$array['acreage']);
if($array['acreage']>-1){
$params[]=$areaArray[0];
$areaArray=explode("-",$array['acreage']);
$params[]=$areaArray[1];
$params[]=$areaArray[0];
if($array['houseType']==0){
$params[]=$areaArray[1];
$sql=$sql." and ada.house_area between %d and %d";
if($array['houseType']==0){
}else{
$sql=$sql." and ada.house_area between %d and %d";
$sql=$sql." and covered_area between %d and %d";
}else{
}
$sql=$sql." and covered_area between %d and %d";
}
}
if($array['unitPrice']>-1){
}
$priceArray=explode("-",$array['unitPrice']);
if($array['unitPrice']>-1){
$params[]=$priceArray[0];
$priceArray=explode("-",$array['unitPrice']);
$params[]=$priceArray[1];
$params[]=$priceArray[0];
$sql=$sql." and average_price between %d and %d";
$params[]=$priceArray[1];
}
$sql=$sql." and average_price between %d and %d";
}
if($array['totalPrice']>-1){
if($array['totalPrice']>-1){
$priceArray=explode("-",$array['totalPrice']);
$priceArray=explode("-",$array['totalPrice']);
$params[]=$priceArray[0];
$params[]=$priceArray[0];
$params[]=$priceArray[1];
$params[]=$priceArray[1];
$sql=$sql." and total_price/10000 between %d and %d";
$sql=$sql." and total_price between %d and %d";
}
}
if($array['rentalPrice']>-1){
if($array['rentalPrice']>-1){
$priceArray=explode("-",$array['rentalPrice']);
$priceArray=explode("-",$array['rentalPrice']);
$params[]=$priceArray[0];
$params[]=$priceArray[0];
$params[]=$priceArray[1];
$params[]=$priceArray[1];
$sql=$sql." and rent between %d and %d";
$sql=$sql." and rent between %d and %d";
}
}
if($array['houseType']>-1){
if($array['houseType']>-1){
$params[]=$array['houseType'];
$params[]=$array['houseType'];
$sql=$sql." and house_type = %d";
$sql=$sql." and house_type = %d";
}
}
if($array['userType']>-1&&$array['userId']>-1){
if($array['userType']>-1&&$array['userId']>-1){
$params[]=$array['userType'];
$params[]=$array['userType'];
$params[]=$array['userId'];
$params[]=$array['userId'];
$sql=$sql." and id in (select house_id from ".Config::A_HOUSE_USER_TABLE." where user_type = %d and user_id = %d)";
$sql=$sql." and id in (select house_id from ".Config::A_HOUSE_USER_TABLE." where user_type = %d and user_id = %d)";
}
}
if($array['searchText']!=null){
if($array['searchText']!=null){
$params[]='%'.$array['searchText'].'%';
$params[]='%'.$array['searchText'].'%';
$params[]='%'.$array['searchText'].'%';
$params[]='%'.$array['searchText'].'%';
$sql=$sql." and (name like '%s' or address like '%s')";
$sql=$sql." and (name like '%s' or address like '%s')";