$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".
$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".
" left join (select value as bp_value,literal as bp_literal from ".Config::DIC_BUILDPROPERTY_TABLE.") dbp on ada.buildproperty_id = dbp.bp_value";
" left join (select value as bp_value,literal as bp_literal from ".Config::DIC_BUILDPROPERTY_TABLE.") dbp on ada.buildproperty_id = dbp.bp_value";
$orderbySql=" group by th.id order by th.creattime DESC";
$orderbySql=" group by th.id order by th.creattime DESC";
}elseif($array['houseType']==1){
}elseif($array['houseType']==1){
$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";
$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";
if($array['feature']>-1){
if($array['feature']>-1){
$addSql.=" left join (select house_id,tag_id from ".Config::A_HOUSE_TAG_TABLE.") aht on th.id = aht.house_id";
$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'];
$addWhereSql=" and tag_id = ".$array['feature'];
}
}
$orderbySql=" order by th.creattime DESC";
$orderbySql=" order by th.creattime DESC";
}elseif($array['houseType']==2){
}elseif($array['houseType']==2){
$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 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".
"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".
" LEFT JOIN ".Config::TOSPUR_TAG_TABLE." tt on tt.id = aht.tag_id".
" where aht.house_id = th.id) as tags from ".Config::TOSPUR_HOUSE_TABLE." th".
" where aht.house_id = th.id) as tags from ".Config::TOSPUR_HOUSE_TABLE." th".
$addSql.
$addSql.
" left join ".Config::DIC_CITY_TABLE." dc on th.plate_id = dc.plateId".
" left join ".Config::DIC_CITY_TABLE." dc on th.plate_id = dc.plateId".
" 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 (select id as rid,value as r_value,literal from ".Config::DIC_ROOM_TABLE.") dr on th.room_id = dr.r_value".
" 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 image_id,path from ".Config::TOSPUR_IMAGE_TABLE.") ti on ti.image_id = th.frontCover_id".
" where 1=1 and th.status = 1 ";
" where 1=1 and th.status = 1 ";
if($array['cityId']>-1){
if($array['cityId']>-1){
$params[]=$array['cityId'];
$params[]=$array['cityId'];
...
@@ -219,7 +280,7 @@ class SearchDao
...
@@ -219,7 +280,7 @@ class SearchDao
$params[]=$array['buildPropertyId'];
$params[]=$array['buildPropertyId'];
if($array['houseType']==0){
if($array['houseType']==0){
$sql=$sql." and ada.buildproperty_id=%d";
$sql=$sql." and ada.buildproperty_id=%d";
}else{
}else{
$sql=$sql." and th.buildproperty_id=%d";
$sql=$sql." and th.buildproperty_id=%d";
}
}
}
}
...
@@ -233,7 +294,7 @@ class SearchDao
...
@@ -233,7 +294,7 @@ class SearchDao
$params[]=$areaArray[1];
$params[]=$areaArray[1];
if($array['houseType']==0){
if($array['houseType']==0){
$sql=$sql." and ada.house_area between %d and %d";
$sql=$sql." and ada.house_area between %d and %d";
}else{
}else{
$sql=$sql." and covered_area between %d and %d";
$sql=$sql." and covered_area between %d and %d";
}
}
}
}
...
@@ -248,7 +309,7 @@ class SearchDao
...
@@ -248,7 +309,7 @@ class SearchDao
$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){
...
@@ -264,15 +325,15 @@ class SearchDao
...
@@ -264,15 +325,15 @@ class SearchDao
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')";