Commit fc27c8f7 by felix

每日一更

parent f93022d6
...@@ -126,8 +126,8 @@ class Contract { ...@@ -126,8 +126,8 @@ class Contract {
$delete_photo_ids = implode(",",$delete_photo_ids); $delete_photo_ids = implode(",",$delete_photo_ids);
if($delete_photo_ids){ if($delete_photo_ids){
$path = ContractDao::searchImgPath($delete_photo_ids); $path = ContractDao::searchImgPath($delete_photo_ids);
$wpdb->query("delete from ".Config::A_CONTRACT_IMAGE_TABLE." where contract_id = {$_REQUEST["id"]} and image_id in ({$delete_photo_ids});"); DBManager::query("delete from ".Config::A_CONTRACT_IMAGE_TABLE." where contract_id = {$_REQUEST["id"]} and image_id in ({$delete_photo_ids});");
$wpdb->query("delete from ".Config::TOSPUR_IMAGE_TABLE." where id in ({$delete_photo_ids});"); DBManager::query("delete from ".Config::TOSPUR_IMAGE_TABLE." where id in ({$delete_photo_ids});");
foreach($path as $value){ foreach($path as $value){
$url = substr_replace(__DIR__,$value->path,strpos(__DIR__,"wp",0)-1); $url = substr_replace(__DIR__,$value->path,strpos(__DIR__,"wp",0)-1);
unlink($url); unlink($url);
......
...@@ -116,7 +116,7 @@ class Contract_List extends WP_List_Table{ ...@@ -116,7 +116,7 @@ class Contract_List extends WP_List_Table{
$sql .= " and (t.consultantId = ".get_current_user_id()." or t.managerId = ".get_current_user_id().")"; $sql .= " and (t.consultantId = ".get_current_user_id()." or t.managerId = ".get_current_user_id().")";
} }
$sql .= " order by t.signedDate desc"; $sql .= " order by t.signedDate desc";
$result = $wpdb->get_results($sql); $result = DBManager::get_results($sql);
$data = array(); $data = array();
foreach ($result as $key => $value) { foreach ($result as $key => $value) {
$data[$key] = array( $data[$key] = array(
......
...@@ -88,11 +88,11 @@ class House extends Tospur_House{ ...@@ -88,11 +88,11 @@ class House extends Tospur_House{
public static function data_update($houseId,$insert_tospur_house_array){ public static function data_update($houseId,$insert_tospur_house_array){
global $wpdb; global $wpdb;
$data = $_POST["data"]; $data = $_POST["data"];
$result = $wpdb->update(Config::TOSPUR_HOUSE_TABLE,$insert_tospur_house_array,array("id" => $houseId)); $result = DBManager::update(Config::TOSPUR_HOUSE_TABLE,$insert_tospur_house_array,array("id" => $houseId));
$exist_ids = array(); $exist_ids = array();
if(isset($_POST['exists'])){ if(isset($_POST['exists'])){
foreach($_POST['exists'] as $id => $item){ foreach($_POST['exists'] as $id => $item){
$wpdb->update(Config::A_DISTRICT_AREA_TABLE,array( DBManager::update(Config::A_DISTRICT_AREA_TABLE,array(
"buildproperty_id" => $item['buildProperty'], "buildproperty_id" => $item['buildProperty'],
"house_area" => $item['housearea'] "house_area" => $item['housearea']
),array("image_id" => $id)); ),array("image_id" => $id));
...@@ -105,14 +105,14 @@ class House extends Tospur_House{ ...@@ -105,14 +105,14 @@ class House extends Tospur_House{
$delete_ids[] = $id; $delete_ids[] = $id;
} }
$delete_ids = implode(",",$delete_ids); $delete_ids = implode(",",$delete_ids);
$wpdb->query("delete from ".Config::A_DISTRICT_AREA_TABLE." where house_id = {$houseId} and image_id in ({$delete_ids});"); DBManager::query("delete from ".Config::A_DISTRICT_AREA_TABLE." where house_id = {$houseId} and image_id in ({$delete_ids});");
$wpdb->query("delete from ".Config::A_HOUSE_IMAGE_TABLE." where house_id = {$houseId} and image_id in ({$delete_ids});"); DBManager::query("delete from ".Config::A_HOUSE_IMAGE_TABLE." where house_id = {$houseId} and image_id in ({$delete_ids});");
InsertDao::addMainImage($houseId,$data); InsertDao::addMainImage($houseId,$data);
$exists_photo_ids = array(); $exists_photo_ids = array();
if(isset($_POST['exists_photo'])){ if(isset($_POST['exists_photo'])){
foreach($_POST['exists_photo'] as $id => $item){ foreach($_POST['exists_photo'] as $id => $item){
$wpdb->update(Config::TOSPUR_IMAGE_TABLE,array( DBManager::update(Config::TOSPUR_IMAGE_TABLE,array(
"image_type" => $item['type'], "image_type" => $item['type'],
),array("id" => $id)); ),array("id" => $id));
$exists_photo_ids[] = $id; $exists_photo_ids[] = $id;
...@@ -124,9 +124,9 @@ class House extends Tospur_House{ ...@@ -124,9 +124,9 @@ class House extends Tospur_House{
$delete_photo_ids[] = $id; $delete_photo_ids[] = $id;
} }
$delete_photo_ids = implode(",",$delete_photo_ids); $delete_photo_ids = implode(",",$delete_photo_ids);
$wpdb->query("delete from ".Config::A_HOUSE_IMAGE_TABLE." where house_id = {$houseId} and image_id in ({$delete_photo_ids});"); DBManager::query("delete from ".Config::A_HOUSE_IMAGE_TABLE." where house_id = {$houseId} and image_id in ({$delete_photo_ids});");
$wpdb->delete(Config::A_HOUSE_RECOMMEND_TABLE,array("house_id" => $houseId)); DBManager::delete(Config::A_HOUSE_RECOMMEND_TABLE,array("house_id" => $houseId));
$result = InsertDao::addRecommend($houseId,$data); $result = InsertDao::addRecommend($houseId,$data);
if(!is_numeric($result)){ if(!is_numeric($result)){
return $result; return $result;
...@@ -149,7 +149,7 @@ class House extends Tospur_House{ ...@@ -149,7 +149,7 @@ class House extends Tospur_House{
//获取新房信息,存入tospur_house表 //获取新房信息,存入tospur_house表
$params['creattime'] = date("Y-m-d H:i:s"); $params['creattime'] = date("Y-m-d H:i:s");
$params['house_type'] = 0; $params['house_type'] = 0;
$res = $wpdb->get_results('SELECT * FROM tospur_house WHERE name="' . $_POST['housename'] . '" and address="' . $_POST['address'] . '" and house_type=0', OBJECT); $res = DBManager::get_results('SELECT * FROM tospur_house WHERE name="' . $_POST['housename'] . '" and address="' . $_POST['address'] . '" and house_type=0', OBJECT);
if (!$res) { if (!$res) {
$houseId = InsertDao::insert_tospur_house($params); $houseId = InsertDao::insert_tospur_house($params);
if(is_numeric($houseId)){ if(is_numeric($houseId)){
......
...@@ -31,7 +31,7 @@ class QuotaMonthList extends WP_List_Table{ ...@@ -31,7 +31,7 @@ class QuotaMonthList extends WP_List_Table{
$sql = "select COUNT(*) as totle,COUNT(NULLIF(quota is not null, false)) as isset,COUNT(NULLIF(quota is null, false)) as unset from ".Config::TOSPUR_CONSULTANT." tc $sql = "select COUNT(*) as totle,COUNT(NULLIF(quota is not null, false)) as isset,COUNT(NULLIF(quota is null, false)) as unset from ".Config::TOSPUR_CONSULTANT." tc
left join ".Config::TOSPUR_QUOTA_TABLE." tq on tq.consultantId = tc.id and tq.year = %d and tq.month = %d left join ".Config::TOSPUR_QUOTA_TABLE." tq on tq.consultantId = tc.id and tq.year = %d and tq.month = %d
where subsidiaryId = %d"; where subsidiaryId = %d";
$result = $wpdb->get_row($wpdb->prepare($sql,$_REQUEST["year"],$_REQUEST["month"],$_REQUEST["oid"])); $result =DBManager::get_row($wpdb->prepare($sql,$_REQUEST["year"],$_REQUEST["month"],$_REQUEST["oid"]));
return array( return array(
"all" => '<a href="'.$current_url.'"'.(isset($_REQUEST["type"])?"":'class="current"').'>全部<span class="count">('.$result->totle.')</span></a>', "all" => '<a href="'.$current_url.'"'.(isset($_REQUEST["type"])?"":'class="current"').'>全部<span class="count">('.$result->totle.')</span></a>',
...@@ -62,7 +62,7 @@ class QuotaMonthList extends WP_List_Table{ ...@@ -62,7 +62,7 @@ class QuotaMonthList extends WP_List_Table{
} }
$sql .=" null"; $sql .=" null";
} }
$result = $wpdb->get_results($wpdb->prepare($sql,$_REQUEST["year"],$_REQUEST["month"],$_REQUEST["oid"])); $result = DBManager::get_results($wpdb->prepare($sql,$_REQUEST["year"],$_REQUEST["month"],$_REQUEST["oid"]));
foreach($result as $key => $value){ foreach($result as $key => $value){
$data[$key] = array( $data[$key] = array(
'id' => $value->id, 'id' => $value->id,
......
...@@ -37,8 +37,8 @@ class QuotaYearList extends WP_List_Table ...@@ -37,8 +37,8 @@ class QuotaYearList extends WP_List_Table
if(isset($_REQUEST["year"]) && isset($_REQUEST["organization"])){ if(isset($_REQUEST["year"]) && isset($_REQUEST["organization"])){
$sql = "select *, month,sum(quota) as quota from ".Config::TOSPUR_QUOTA_TABLE." where consultantId in(select id from ".Config::TOSPUR_CONSULTANT." $sql = "select *, month,sum(quota) as quota from ".Config::TOSPUR_QUOTA_TABLE." where consultantId in(select id from ".Config::TOSPUR_CONSULTANT."
where subsidiaryId = %d) and year = %d group by year,month;"; where subsidiaryId = %d) and year = %d group by year,month;";
$result = $wpdb->get_results($wpdb->prepare($sql,$_REQUEST["organization"],$_REQUEST["year"])); $result = DBManager::get_results($wpdb->prepare($sql,$_REQUEST["organization"],$_REQUEST["year"]));
$name = $wpdb->get_var($wpdb->prepare("select Name from tospur_organization where id = %d;",$_REQUEST["organization"])); $name = DBManager::get_var($wpdb->prepare("select Name from tospur_organization where id = %d;",$_REQUEST["organization"]));
$j = 0; $j = 0;
for($i = 1;$i<=12;$i++){ for($i = 1;$i<=12;$i++){
$item = $result[$j]; $item = $result[$j];
......
...@@ -11,7 +11,7 @@ class Statistics { ...@@ -11,7 +11,7 @@ class Statistics {
where house_type >0 and creattime >= '".$today."' and where house_type >0 and creattime >= '".$today."' and
creattime<DATE_SUB('".$today."', INTERVAL -1 DAY) creattime<DATE_SUB('".$today."', INTERVAL -1 DAY)
group by user_id,house_type;"; group by user_id,house_type;";
$result = $wpdb->get_results($sql); $result = DBManager::get_results($sql);
if(!$wpdb->last_error){ if(!$wpdb->last_error){
foreach($result as $item){ foreach($result as $item){
if(!$consultant[$item->consultantId]){ if(!$consultant[$item->consultantId]){
...@@ -41,7 +41,7 @@ class Statistics { ...@@ -41,7 +41,7 @@ class Statistics {
where time >= '".$today."' where time >= '".$today."'
and time<DATE_SUB('".$today."', INTERVAL -1 DAY) and time<DATE_SUB('".$today."', INTERVAL -1 DAY)
group by consultant_id;"; group by consultant_id;";
$result = $wpdb->get_results($sql); $result = DBManager::get_results($sql);
if(!$wpdb->last_error){ if(!$wpdb->last_error){
foreach($result as $item){ foreach($result as $item){
if(!$consultant[$item->consultantId]){ if(!$consultant[$item->consultantId]){
...@@ -82,7 +82,7 @@ class Statistics { ...@@ -82,7 +82,7 @@ class Statistics {
where tct.time >= '".$today."' where tct.time >= '".$today."'
and tct.time < DATE_SUB('".$today."', INTERVAL -1 DAY) and tct.time < DATE_SUB('".$today."', INTERVAL -1 DAY)
group by consultant_id;"; group by consultant_id;";
$result = $wpdb->get_results($sql); $result = DBManager::get_results($sql);
if(!$wpdb->last_error){ if(!$wpdb->last_error){
foreach($result as $item){ foreach($result as $item){
if(!$consultant[$item->consultantId]){ if(!$consultant[$item->consultantId]){
...@@ -109,7 +109,7 @@ class Statistics { ...@@ -109,7 +109,7 @@ class Statistics {
and dealTime >= '".$today."' and dealTime >= '".$today."'
and dealTime < DATE_SUB('".$today."', INTERVAL -1 DAY)) and dealTime < DATE_SUB('".$today."', INTERVAL -1 DAY))
group by consultantId;"; group by consultantId;";
$result = $wpdb->get_results($sql); $result = DBManager::get_results($sql);
//print_r($wpdb->last_query); //print_r($wpdb->last_query);
if(!$wpdb->last_error){ if(!$wpdb->last_error){
foreach($result as $item){ foreach($result as $item){
...@@ -133,7 +133,7 @@ class Statistics { ...@@ -133,7 +133,7 @@ class Statistics {
} }
$sql = "select consultantId,quota from tospur_quota where year = ".$year." and month = ".$month.";"; $sql = "select consultantId,quota from tospur_quota where year = ".$year." and month = ".$month.";";
$result = $wpdb->get_results($sql); $result = DBManager::get_results($sql);
if(!$wpdb->last_error){ if(!$wpdb->last_error){
foreach($result as $item){ foreach($result as $item){
if(!$consultant[$item->consultantId]){ if(!$consultant[$item->consultantId]){
...@@ -157,7 +157,7 @@ class Statistics { ...@@ -157,7 +157,7 @@ class Statistics {
tospur_commission where mtime >= '".$today."' tospur_commission where mtime >= '".$today."'
and mtime < DATE_SUB('".$today."', INTERVAL -1 DAY) and mtime < DATE_SUB('".$today."', INTERVAL -1 DAY)
group by consultantId;"; group by consultantId;";
$result = $wpdb->get_results($sql); $result = DBManager::get_results($sql);
if(!$wpdb->last_error){ if(!$wpdb->last_error){
foreach($result as $item){ foreach($result as $item){
if(!$consultant[$item->consultantId]){ if(!$consultant[$item->consultantId]){
...@@ -182,7 +182,7 @@ class Statistics { ...@@ -182,7 +182,7 @@ class Statistics {
where time >= '".$today."' where time >= '".$today."'
and time < DATE_SUB('".$today."', INTERVAL -1 DAY) and time < DATE_SUB('".$today."', INTERVAL -1 DAY)
group by tc.consultantId;"; group by tc.consultantId;";
$result = $wpdb->get_results($sql); $result = DBManager::get_results($sql);
if(!$wpdb->last_error){ if(!$wpdb->last_error){
foreach($result as $item){ foreach($result as $item){
if(!$consultant[$item->consultantId]){ if(!$consultant[$item->consultantId]){
...@@ -205,7 +205,7 @@ class Statistics { ...@@ -205,7 +205,7 @@ class Statistics {
$sql = "select sum(if(house_type = 1,1,0)) sell,sum(if(house_type = 2,1,0)) lease,ahu.user_id as consultantId from a_house_user ahu $sql = "select sum(if(house_type = 1,1,0)) sell,sum(if(house_type = 2,1,0)) lease,ahu.user_id as consultantId from a_house_user ahu
left join tospur_house th on th.id = ahu.house_id left join tospur_house th on th.id = ahu.house_id
where th.house_type > 0 and user_type = 1 group by ahu.user_id;"; where th.house_type > 0 and user_type = 1 group by ahu.user_id;";
$result = $wpdb->get_results($sql); $result = DBManager::get_results($sql);
if(!$wpdb->last_error){ if(!$wpdb->last_error){
foreach($result as $item){ foreach($result as $item){
if(!$consultant[$item->consultantId]){ if(!$consultant[$item->consultantId]){
...@@ -228,7 +228,7 @@ class Statistics { ...@@ -228,7 +228,7 @@ class Statistics {
} }
$sql = "select consultant_id as consultantId,sum(secondHand_house) as stockSellC,sum(rent_house) as stockLeaseC from tospur_customer where status = 0 group by consultant_id;"; $sql = "select consultant_id as consultantId,sum(secondHand_house) as stockSellC,sum(rent_house) as stockLeaseC from tospur_customer where status = 0 group by consultant_id;";
$result = $wpdb->get_results($sql); $result = DBManager::get_results($sql);
if(!$wpdb->last_error){ if(!$wpdb->last_error){
foreach($result as $item){ foreach($result as $item){
if(!$consultant[$item->consultantId]){ if(!$consultant[$item->consultantId]){
...@@ -263,11 +263,11 @@ class Statistics { ...@@ -263,11 +263,11 @@ class Statistics {
public static function updateBusiness($params,$where){ public static function updateBusiness($params,$where){
global $wpdb; global $wpdb;
$result = $wpdb->update(Config::STATISTICS_BUSINESS,$params,$where); $result = DBManager::update(Config::STATISTICS_BUSINESS,$params,$where);
if($result === 0){ if($result === 0){
$result = $wpdb->get_row($wpdb->prepare("select * from ".Config::STATISTICS_BUSINESS." where consultantId=%d and date = %s",$where["consultantId"],$where["date"])); $result = DBManager::get_row($wpdb->prepare("select * from ".Config::STATISTICS_BUSINESS." where consultantId=%d and date = %s",$where["consultantId"],$where["date"]));
if(!$result) if(!$result)
$wpdb->insert(Config::STATISTICS_BUSINESS,array_merge($params,$where)); DBManager::insert(Config::STATISTICS_BUSINESS,array_merge($params,$where));
} }
} }
} }
\ No newline at end of file
...@@ -59,9 +59,9 @@ class Tospur_House{ ...@@ -59,9 +59,9 @@ class Tospur_House{
$string = null; $string = null;
$user_id = get_current_user_id(); $user_id = get_current_user_id();
if($user_id){ if($user_id){
$res = $wpdb->get_row("select subsidiaryId from ".Config::TOSPUR_CONSULTANT." where id = ".$user_id); $res = DBManager::get_row("select subsidiaryId from ".Config::TOSPUR_CONSULTANT." where id = ".$user_id);
if($res){ if($res){
$results = $wpdb->get_results("select id from ".Config::TOSPUR_CONSULTANT." where subsidiaryId = ".$res->subsidiaryId); $results = DBManager::get_results("select id from ".Config::TOSPUR_CONSULTANT." where subsidiaryId = ".$res->subsidiaryId);
$resArray =array(); $resArray =array();
foreach($results as $key=>$value) { foreach($results as $key=>$value) {
$resArray[$key] = $value->id; $resArray[$key] = $value->id;
......
...@@ -118,7 +118,7 @@ class commissionList extends WP_List_Table ...@@ -118,7 +118,7 @@ class commissionList extends WP_List_Table
$sql = $sql . " and tc.consultant_name like '%" . $_REQUEST['search_consultant_name'] . "%'"; $sql = $sql . " and tc.consultant_name like '%" . $_REQUEST['search_consultant_name'] . "%'";
} }
$result = $wpdb->get_results($sql); $result = DBManager::get_results($sql);
$data = array(); $data = array();
foreach ($result as $key => $value) { foreach ($result as $key => $value) {
......
...@@ -76,7 +76,7 @@ class CommissionManage{ ...@@ -76,7 +76,7 @@ class CommissionManage{
"consultanId" => $data["recConsultant"], "consultanId" => $data["recConsultant"],
"type" => $_POST["businessType"] "type" => $_POST["businessType"]
); );
$updateRes = $wpdb->update(Config::TOSPUR_COMMISSION,$updateParam,array("contractId" => $contractId)); $updateRes = DBManager::update(Config::TOSPUR_COMMISSION,$updateParam,array("contractId" => $contractId));
$commission = CommissionDao::search_tospur_commission($contractId); $commission = CommissionDao::search_tospur_commission($contractId);
if(is_numeric($updateRes)){ if(is_numeric($updateRes)){
if(isset( $_POST["log"])) { if(isset( $_POST["log"])) {
......
...@@ -5,7 +5,7 @@ class introduction ...@@ -5,7 +5,7 @@ class introduction
public static function submit_introduction($time, $introduction, $user_id) public static function submit_introduction($time, $introduction, $user_id)
{ {
global $wpdb; global $wpdb;
$result = $wpdb->update( $result = DBManager::update(
Config::TOSPUR_CONSULTANT, Config::TOSPUR_CONSULTANT,
array( array(
'time' => $time, 'time' => $time,
...@@ -21,7 +21,7 @@ class introduction ...@@ -21,7 +21,7 @@ class introduction
public static function updateQRcode($user_id,$url){ public static function updateQRcode($user_id,$url){
global $wpdb; global $wpdb;
$result = $wpdb->update( $result = DBManager::update(
Config::TOSPUR_CONSULTANT, Config::TOSPUR_CONSULTANT,
array( array(
'QRcodeImg' => $url, 'QRcodeImg' => $url,
...@@ -37,7 +37,7 @@ class introduction ...@@ -37,7 +37,7 @@ class introduction
public static function search_consultant_results($user_id){ public static function search_consultant_results($user_id){
global $wpdb; global $wpdb;
$sql = "select time,introduction,QRcodeImg from " . Config::TOSPUR_CONSULTANT . " where id = %d"; $sql = "select time,introduction,QRcodeImg from " . Config::TOSPUR_CONSULTANT . " where id = %d";
$result = $wpdb->get_row($wpdb->prepare($sql,$user_id)); $result = DBManager::get_row($wpdb->prepare($sql,$user_id));
if($wpdb->last_error){ if($wpdb->last_error){
return $wpdb->last_error; return $wpdb->last_error;
} }
...@@ -86,7 +86,7 @@ class introduction ...@@ -86,7 +86,7 @@ class introduction
$time = $_POST['time']; $time = $_POST['time'];
$introduction = $_POST['introduction']; $introduction = $_POST['introduction'];
$user_id = $_POST['user_id']; $user_id = $_POST['user_id'];
$result = $wpdb->update( $result = DBManager::update(
Config::TOSPUR_CONSULTANT, Config::TOSPUR_CONSULTANT,
array( array(
'time' => $time, 'time' => $time,
......
...@@ -20,7 +20,7 @@ class newHouseList extends WP_List_Table ...@@ -20,7 +20,7 @@ class newHouseList extends WP_List_Table
COUNT(NULLIF(status = -1, false)) as onSaleNum, COUNT(NULLIF(status = -1, false)) as onSaleNum,
COUNT(NULLIF(status = 2, false)) as notSaleNum COUNT(NULLIF(status = 2, false)) as notSaleNum
from " . Config::TOSPUR_HOUSE_TABLE . " where house_type = 0"; from " . Config::TOSPUR_HOUSE_TABLE . " where house_type = 0";
$result = $wpdb->get_results($sql); $result = DBManager::get_results($sql);
foreach ($result as $value) { foreach ($result as $value) {
$approvalParam = array( $approvalParam = array(
"allNum" => $value->allNum, "allNum" => $value->allNum,
...@@ -173,14 +173,14 @@ class newHouseList extends WP_List_Table ...@@ -173,14 +173,14 @@ class newHouseList extends WP_List_Table
$id = $_REQUEST['newhouselist']; $id = $_REQUEST['newhouselist'];
if ($id) { if ($id) {
$string = '(' . implode(',', array_map('intval', $id)) . ')'; $string = '(' . implode(',', array_map('intval', $id)) . ')';
$approvalRes = $wpdb->get_results('select approval from tospur_house where id in ' . $string); $approvalRes = DBManager::get_results('select approval from tospur_house where id in ' . $string);
foreach ($approvalRes as $value) { foreach ($approvalRes as $value) {
if ($value->approval == -2) { if ($value->approval == -2) {
print_r("您审批的房源中含有未申请审批的房源,请重新选择"); print_r("您审批的房源中含有未申请审批的房源,请重新选择");
exit; exit;
} }
} }
$result = $wpdb->query('update tospur_house th SET th.status= th.approval where id in ' . $string); $result = DBManager::query('update tospur_house th SET th.status= th.approval where id in ' . $string);
$flag = 1; $flag = 1;
} }
break; break;
...@@ -194,7 +194,7 @@ class newHouseList extends WP_List_Table ...@@ -194,7 +194,7 @@ class newHouseList extends WP_List_Table
} }
if ($flag == 1) { if ($flag == 1) {
$wpdb->query('update tospur_house th SET th.approval= -2 where id in ' . $string); DBManager::query('update tospur_house th SET th.approval= -2 where id in ' . $string);
} }
} }
} }
...@@ -203,7 +203,7 @@ class newHouseList extends WP_List_Table ...@@ -203,7 +203,7 @@ class newHouseList extends WP_List_Table
{ {
global $wpdb; global $wpdb;
$sql = "select status from tospur_house where id in" . $houseId; $sql = "select status from tospur_house where id in" . $houseId;
$res = $wpdb->get_results($sql); $res = DBManager::get_results($sql);
if ($changeStatus != null || $changeStatus == 0) { if ($changeStatus != null || $changeStatus == 0) {
foreach ($res as $value) { foreach ($res as $value) {
if ($value->status == $changeStatus) { if ($value->status == $changeStatus) {
...@@ -258,7 +258,7 @@ class newHouseList extends WP_List_Table ...@@ -258,7 +258,7 @@ class newHouseList extends WP_List_Table
break; break;
} }
} }
$result = $wpdb->query($wpdb->prepare('update tospur_house SET approval=%d where id in ' . $string, $status)); $result = DBManager::query($wpdb->prepare('update tospur_house SET status = 0 , approval=%d where id in ' . $string, $status));
} }
} }
...@@ -361,7 +361,7 @@ class newHouseList extends WP_List_Table ...@@ -361,7 +361,7 @@ class newHouseList extends WP_List_Table
$sql = $sql . " order by " . $orderby . " " . $order; $sql = $sql . " order by " . $orderby . " " . $order;
} }
$result = $wpdb->get_results($wpdb->prepare($sql, $params)); $result = DBManager::get_results($wpdb->prepare($sql, $params));
$data = array(); $data = array();
foreach ($result as $key => $value) { foreach ($result as $key => $value) {
$data[$key] = array( $data[$key] = array(
......
...@@ -29,7 +29,7 @@ class progressList extends WP_List_Table ...@@ -29,7 +29,7 @@ class progressList extends WP_List_Table
} ?>> } ?>>
<?php $this->display_rows_or_placeholder(); ?> <?php $this->display_rows_or_placeholder(); ?>
<?php <?php
if ( $this->has_items() ) { if ($this->has_items()) {
global $progress_sql; global $progress_sql;
$result = DBManager::get_row($progress_sql); $result = DBManager::get_row($progress_sql);
$achieving_rate = 0; $achieving_rate = 0;
...@@ -38,22 +38,22 @@ class progressList extends WP_List_Table ...@@ -38,22 +38,22 @@ class progressList extends WP_List_Table
} }
echo '<tr> echo '<tr>
<td>合计</td> <td>合计</td>
<td class="sum_newSell">' . $result->sum_newSell . '</td> <td class="newSell">' . $result->newSell . '</td>
<td class="sum_newLease">' . $result->sum_newLease . '</td> <td class="newLease">' . $result->newLease . '</td>
<td class="sum_newBuy">' . $result->sum_newBuy . '</td> <td class="newBuy">' . $result->newBuy . '</td>
<td class="sum_newTenant">' . $result->sum_newTenant . '</td> <td class="newTenant">' . $result->newTenant . '</td>
<td class="sum_business">' . $result->sum_business . '</td> <td class="business">' . $result->business . '</td>
<td class="sum_lease">' . $result->sum_lease . '</td> <td class="lease">' . $result->lease . '</td>
<td class="sum_dealBusiness">' . $result->sum_dealBusiness . '</td> <td class="dealBusiness">' . $result->dealBusiness . '</td>
<td class="sum_dealLease">' . $result->sum_dealLease . '</td> <td class="dealLease">' . $result->dealLease . '</td>
<td class="sum_quota">' . round($result->sum_quota / 10000, 2) . '</td> <td class="quota">' . round($result->quota / 10000, 2) . '</td>
<td class="achieving_rate">' . round($achieving_rate, 2) . '%</td> <td class="achieving_rate">' . round($achieving_rate, 2) . '%</td>
<td class="sum_accounts">' . round($result->sum_accounts / 10000, 2) . '</td> <td class="accounts">' . round($result->accounts / 10000, 2) . '</td>
<td class="sum_paid">' . round($result->sum_paid / 10000, 2) . '</td> <td class="paid">' . round($result->paid / 10000, 2) . '</td>
<td class="sum_stockSellH">' . $result->sum_stockSellH . '</td> <td class="stockSellH">' . $result->stockSellH . '</td>
<td class="sum_stockLeaseH">' . $result->sum_stockLeaseH . '</td> <td class="stockLeaseH">' . $result->stockLeaseH . '</td>
<td class="sum_stockSellC">' . $result->sum_stockSellC . '</td> <td class="stockSellC">' . $result->stockSellC . '</td>
<td class="sum_stockLeaseC">' . $result->sum_stockLeaseC . '</td> <td class="stockLeaseC">' . $result->stockLeaseC . '</td>
</tr>'; </tr>';
} }
?> ?>
...@@ -97,29 +97,29 @@ class progressList extends WP_List_Table ...@@ -97,29 +97,29 @@ class progressList extends WP_List_Table
function get_columns() function get_columns()
{ {
$columns['organization'] = '部门'; $columns['organization'] = '部门';
$columns['sum_newSell'] = '出售'; $columns['newSell'] = '出售';
$columns['sum_newLease'] = '出租'; $columns['newLease'] = '出租';
$columns['sum_newBuy'] = '求购'; $columns['newBuy'] = '求购';
$columns['sum_newTenant'] = '求租'; $columns['newTenant'] = '求租';
$columns['sum_business'] = '买卖'; $columns['business'] = '买卖';
$columns['sum_lease'] = '租赁'; $columns['lease'] = '租赁';
$columns['sum_dealBusiness'] = '买卖'; $columns['dealBusiness'] = '买卖';
$columns['sum_dealLease'] = '租赁'; $columns['dealLease'] = '租赁';
$columns['sum_quota'] = '金额(万)'; $columns['quota'] = '金额(万)';
$columns['achieving_rate'] = '达成率%'; $columns['achieving_rate'] = '达成率%';
$columns['sum_accounts'] = '金额(万)'; $columns['accounts'] = '金额(万)';
$columns['sum_paid'] = '金额(万)'; $columns['paid'] = '金额(万)';
$columns['sum_stockSellH'] = '出售'; $columns['stockSellH'] = '出售';
$columns['sum_stockLeaseH'] = '出租'; $columns['stockLeaseH'] = '出租';
$columns['sum_stockSellC'] = '求购'; $columns['stockSellC'] = '求购';
$columns['sum_stockLeaseC'] = '求租'; $columns['stockLeaseC'] = '求租';
return $columns; return $columns;
} }
...@@ -133,12 +133,14 @@ class progressList extends WP_List_Table ...@@ -133,12 +133,14 @@ class progressList extends WP_List_Table
$this->_column_headers = array($columns, $hidden); $this->_column_headers = array($columns, $hidden);
$sql = "select p.id,p.consultantId,p.name as consultant_name,p.subsidiaryId,p.organization,p.date, $sql = "select q.*,sum(sb2.quota) as quota,(sum(q.paid)/sum(sb2.quota)) as achieving_rate,
sum(p.newSell) as sum_newSell,sum(p.newLease) as sum_newLease,sum(p.newBuy) as sum_newBuy,sum(p.newTenant) as sum_newTenant, sum(sb2.stockSellH) as stockSellH,sum(sb2.stockLeaseH) as stockLeaseH,
sum(p.business) as sum_business,sum(p.lease) as sum_lease,sum(p.dealBusiness) as sum_dealBusiness,sum(p.dealLease) as sum_dealLease, sum(sb2.stockSellC) as stockSellC,sum(sb2.stockLeaseC) as stockLeaseC
sum(p.quota) as sum_quota,sum(p.accounts) as sum_accounts,sum(p.paid) as sum_paid,(sum(p.paid)/sum(p.quota)) as achieving_rate, from (select p.id,p.name,p.subsidiaryId,p.organization,
sum(p.stockSellH) as sum_stockSellH,sum(p.stockLeaseH) as sum_stockLeaseH,sum(p.stockSellC) as sum_stockSellC,sum(p.stockLeaseC) as sum_stockLeaseC sum(p.newSell) as newSell,sum(p.newLease) as newLease,sum(p.newBuy) as newBuy,sum(p.newTenant) as newTenant,
from (SELECT tc.name,sb.*,tc.subsidiaryId,torg.Name as organization FROM statistics_business sb sum(p.business) as business,sum(p.lease) as lease,sum(p.dealBusiness) as dealBusiness,sum(p.dealLease) as dealLease,
sum(p.accounts) as accounts,sum(p.paid) as paid
from (select tc.name,tc.subsidiaryId,torg.Name as organization,sb.* from statistics_business sb
left join tospur_consultant tc on sb.consultantId = tc.id left join tospur_consultant tc on sb.consultantId = tc.id
left join tospur_organization torg on tc.subsidiaryId = torg.Id left join tospur_organization torg on tc.subsidiaryId = torg.Id
where 1 = 1"; where 1 = 1";
...@@ -165,9 +167,10 @@ sum(p.stockSellH) as sum_stockSellH,sum(p.stockLeaseH) as sum_stockLeaseH,sum(p. ...@@ -165,9 +167,10 @@ sum(p.stockSellH) as sum_stockSellH,sum(p.stockLeaseH) as sum_stockLeaseH,sum(p.
$sql .= " and sb.date >= '" . $_REQUEST['year'] . "-1-1' and sb.date < DATE_SUB('" . $_REQUEST['year'] . "-1-1', INTERVAL -1 YEAR)"; $sql .= " and sb.date >= '" . $_REQUEST['year'] . "-1-1' and sb.date < DATE_SUB('" . $_REQUEST['year'] . "-1-1', INTERVAL -1 YEAR)";
} }
$sql .= " order by sb.id desc) p"; $sql .= " order by sb.id desc) p group by p.consultantId) q
left join statistics_business sb2 on q.id = sb2.id";
$progress_sql = $sql; $progress_sql = $sql;
$sql .= " group by p.subsidiaryId"; $sql .= " group by q.subsidiaryId";
$result = DBManager::get_results($sql); $result = DBManager::get_results($sql);
$data = array(); $data = array();
foreach ($result as $key => $value) { foreach ($result as $key => $value) {
...@@ -177,22 +180,22 @@ sum(p.stockSellH) as sum_stockSellH,sum(p.stockLeaseH) as sum_stockLeaseH,sum(p. ...@@ -177,22 +180,22 @@ sum(p.stockSellH) as sum_stockSellH,sum(p.stockLeaseH) as sum_stockLeaseH,sum(p.
} }
$data[$key] = array( $data[$key] = array(
'organization' => $value->organization, 'organization' => $value->organization,
'sum_newSell' => $value->sum_newSell, 'newSell' => $value->newSell,
'sum_newLease' => $value->sum_newLease, 'newLease' => $value->newLease,
'sum_newBuy' => $value->sum_newBuy, 'newBuy' => $value->newBuy,
'sum_newTenant' => $value->sum_newTenant, 'newTenant' => $value->newTenant,
'sum_business' => $value->sum_business, 'business' => $value->business,
'sum_lease' => $value->sum_lease, 'lease' => $value->lease,
'sum_dealBusiness' => $value->sum_dealBusiness, 'dealBusiness' => $value->dealBusiness,
'sum_dealLease' => $value->sum_dealLease, 'dealLease' => $value->dealLease,
'sum_quota' => round($value->sum_quota / 10000, 2), 'quota' => round($value->quota / 10000, 2),
'achieving_rate' => round($achieving_rate, 2) . '%', 'achieving_rate' => round($achieving_rate, 2) . '%',
'sum_accounts' => round($value->sum_accounts / 10000, 2), 'accounts' => round($value->accounts / 10000, 2),
'sum_paid' => round($value->sum_paid / 10000, 2), 'paid' => round($value->paid / 10000, 2),
'sum_stockSellH' => $value->sum_stockSellH, 'stockSellH' => $value->stockSellH,
'sum_stockLeaseH' => $value->sum_stockLeaseH, 'stockLeaseH' => $value->stockLeaseH,
'sum_stockSellC' => $value->sum_stockSellC, 'stockSellC' => $value->stockSellC,
'sum_stockLeaseC' => $value->sum_stockLeaseC 'stockLeaseC' => $value->stockLeaseC
); );
} }
......
...@@ -108,7 +108,7 @@ class RentHouse extends Tospur_House{ ...@@ -108,7 +108,7 @@ class RentHouse extends Tospur_House{
$data = $_POST["data"]; $data = $_POST["data"];
$params['creattime'] = date("Y-m-d H:i:s"); $params['creattime'] = date("Y-m-d H:i:s");
$params['house_type'] = 2; $params['house_type'] = 2;
$res = $wpdb->get_results('SELECT * FROM tospur_house WHERE address="' .$params['address'] . '" and owner_name="' .$params['owner_name'] . '" and owner_phone="'.$params['owner_phone'].'" and house_type=2', OBJECT); $res = DBManager::get_results('SELECT * FROM tospur_house WHERE address="' .$params['address'] . '" and owner_name="' .$params['owner_name'] . '" and owner_phone="'.$params['owner_phone'].'" and house_type=2', OBJECT);
if(!$res){ if(!$res){
$houseId = InsertDao::insert_tospur_house($params); $houseId = InsertDao::insert_tospur_house($params);
if(is_numeric($houseId)){ if(is_numeric($houseId)){
...@@ -152,12 +152,12 @@ class RentHouse extends Tospur_House{ ...@@ -152,12 +152,12 @@ class RentHouse extends Tospur_House{
public static function data_update($houseId,$params){ public static function data_update($houseId,$params){
global $wpdb; global $wpdb;
$data = $_POST["data"]; $data = $_POST["data"];
$result = $wpdb->update(Config::TOSPUR_HOUSE_TABLE,$params,array("id" => $houseId)); $result = DBManager::update(Config::TOSPUR_HOUSE_TABLE,$params,array("id" => $houseId));
InsertDao::addMainImage($houseId,$data); InsertDao::addMainImage($houseId,$data);
$exists_photo_ids = array(); $exists_photo_ids = array();
if(isset($_POST['exists_photo'])){ if(isset($_POST['exists_photo'])){
foreach($_POST['exists_photo'] as $id => $item){ foreach($_POST['exists_photo'] as $id => $item){
$wpdb->update(Config::TOSPUR_IMAGE_TABLE,array( DBManager::update(Config::TOSPUR_IMAGE_TABLE,array(
"image_type" => $item['type'], "image_type" => $item['type'],
),array("id" => $id)); ),array("id" => $id));
$exists_photo_ids[] = $id; $exists_photo_ids[] = $id;
...@@ -169,9 +169,9 @@ class RentHouse extends Tospur_House{ ...@@ -169,9 +169,9 @@ class RentHouse extends Tospur_House{
$delete_photo_ids[] = $id; $delete_photo_ids[] = $id;
} }
$delete_photo_ids = implode(",",$delete_photo_ids); $delete_photo_ids = implode(",",$delete_photo_ids);
$wpdb->query("delete from ".Config::A_HOUSE_IMAGE_TABLE." where house_id = {$houseId} and image_id in ({$delete_photo_ids});"); DBManager::query("delete from ".Config::A_HOUSE_IMAGE_TABLE." where house_id = {$houseId} and image_id in ({$delete_photo_ids});");
$wpdb->delete(Config::A_HOUSE_RECOMMEND_TABLE,array("house_id" => $houseId)); DBManager::delete(Config::A_HOUSE_RECOMMEND_TABLE,array("house_id" => $houseId));
$result = InsertDao::addRecommend($houseId,$data); $result = InsertDao::addRecommend($houseId,$data);
if(!is_numeric($result)){ if(!is_numeric($result)){
return $result; return $result;
......
...@@ -29,7 +29,7 @@ class rentHouseList extends WP_List_Table ...@@ -29,7 +29,7 @@ class rentHouseList extends WP_List_Table
$select = $select." left join(select user_id as aus_id,house_id from a_house_user) ahu on th.id = ahu.house_id"; $select = $select." left join(select user_id as aus_id,house_id from a_house_user) ahu on th.id = ahu.house_id";
$where = $where." and aus_id in ".$consultantArray; $where = $where." and aus_id in ".$consultantArray;
} }
$result = $wpdb->get_results($select.$where); $result = DBManager::get_results($select.$where);
foreach ($result as $value) { foreach ($result as $value) {
$approvalParam = array( $approvalParam = array(
"allNum" => $value->allNum, "allNum" => $value->allNum,
...@@ -172,14 +172,14 @@ class rentHouseList extends WP_List_Table ...@@ -172,14 +172,14 @@ class rentHouseList extends WP_List_Table
$flag = 0; $flag = 0;
switch ($action) { switch ($action) {
case"agree": case"agree":
$approvalRes = $wpdb->get_results('select approval from tospur_house where id in ' . $string); $approvalRes = DBManager::get_results('select approval from tospur_house where id in ' . $string);
foreach ($approvalRes as $value) { foreach ($approvalRes as $value) {
if ($value->approval == -2) { if ($value->approval == -2) {
print_r("您审批的房源中含有未申请审批的房源,请重新选择"); print_r("您审批的房源中含有未申请审批的房源,请重新选择");
exit; exit;
} }
} }
$result = $wpdb->query('update tospur_house th SET th.status= th.approval where id in ' . $string); $result = DBManager::query('update tospur_house th SET th.status= th.approval where id in ' . $string);
$flag = 1; $flag = 1;
break; break;
case"goBack": case"goBack":
...@@ -190,7 +190,7 @@ class rentHouseList extends WP_List_Table ...@@ -190,7 +190,7 @@ class rentHouseList extends WP_List_Table
break; break;
} }
if ($flag == 1) { if ($flag == 1) {
$wpdb->query('update tospur_house th SET th.approval= -2 where id in ' . $string); DBManager::query('update tospur_house th SET th.approval= -2 where id in ' . $string);
} }
} }
} }
...@@ -199,7 +199,7 @@ class rentHouseList extends WP_List_Table ...@@ -199,7 +199,7 @@ class rentHouseList extends WP_List_Table
{ {
global $wpdb; global $wpdb;
$sql = "select status from tospur_house where id in" . $houseId; $sql = "select status from tospur_house where id in" . $houseId;
$res = $wpdb->get_results($sql); $res = DBManager::get_results($sql);
foreach ($res as $value) { foreach ($res as $value) {
if ($value->status == $changeStatus) { if ($value->status == $changeStatus) {
print_r("您申请的状态含有与原状态相同的房源,请重新选择"); print_r("您申请的状态含有与原状态相同的房源,请重新选择");
...@@ -283,7 +283,7 @@ class rentHouseList extends WP_List_Table ...@@ -283,7 +283,7 @@ class rentHouseList extends WP_List_Table
$status = $res; $status = $res;
break; break;
} }
$result = $wpdb->query($wpdb->prepare('update tospur_house SET approval=%d where id in ' . $string, $status)); $result = DBManager::query($wpdb->prepare('update tospur_house SET status = 0 ,approval=%d where id in ' . $string, $status));
} }
} }
...@@ -389,7 +389,7 @@ class rentHouseList extends WP_List_Table ...@@ -389,7 +389,7 @@ class rentHouseList extends WP_List_Table
$order = $_GET["order"]; $order = $_GET["order"];
$sql = $sql . " order by " . $orderby . " " . $order; $sql = $sql . " order by " . $orderby . " " . $order;
} }
$result = $wpdb->get_results($wpdb->prepare($sql, $params)); $result = DBManager::get_results($wpdb->prepare($sql, $params));
$data = array(); $data = array();
foreach ($result as $key => $value) { foreach ($result as $key => $value) {
$data[$key] = array( $data[$key] = array(
......
...@@ -108,7 +108,7 @@ class SecHandHouse extends Tospur_House{ ...@@ -108,7 +108,7 @@ class SecHandHouse extends Tospur_House{
$params['creattime'] = date("Y-m-d H:i:s"); $params['creattime'] = date("Y-m-d H:i:s");
$params['house_type'] = 1; $params['house_type'] = 1;
//获取新房信息,存入tospur_house表 //获取新房信息,存入tospur_house表
$res = $wpdb->get_results('SELECT * FROM tospur_house WHERE address="' .$params['address'] . '" and owner_name="' .$params['owner_name'] . '" and owner_phone="'.$params['owner_phone'].'" and house_type=1', OBJECT); $res = DBManager::get_results('SELECT * FROM tospur_house WHERE address="' .$params['address'] . '" and owner_name="' .$params['owner_name'] . '" and owner_phone="'.$params['owner_phone'].'" and house_type=1', OBJECT);
if(!$res){ if(!$res){
$houseId = InsertDao::insert_tospur_house($params); $houseId = InsertDao::insert_tospur_house($params);
if(is_numeric($houseId)){ if(is_numeric($houseId)){
...@@ -151,7 +151,7 @@ class SecHandHouse extends Tospur_House{ ...@@ -151,7 +151,7 @@ class SecHandHouse extends Tospur_House{
public static function data_update($houseId,$params){ public static function data_update($houseId,$params){
global $wpdb; global $wpdb;
$data = $_POST["data"]; $data = $_POST["data"];
$res = $wpdb->update(Config::TOSPUR_HOUSE_TABLE,$params,array("id" => $houseId)); $res = DBManager::update(Config::TOSPUR_HOUSE_TABLE,$params,array("id" => $houseId));
$result = 201; $result = 201;
InsertDao::addMainImage($houseId,$data); InsertDao::addMainImage($houseId,$data);
...@@ -159,7 +159,7 @@ class SecHandHouse extends Tospur_House{ ...@@ -159,7 +159,7 @@ class SecHandHouse extends Tospur_House{
$exists_photo_ids = array(); $exists_photo_ids = array();
if(isset($_POST['exists_photo'])){ if(isset($_POST['exists_photo'])){
foreach($_POST['exists_photo'] as $id => $item){ foreach($_POST['exists_photo'] as $id => $item){
$wpdb->update(Config::TOSPUR_IMAGE_TABLE,array( DBManager::update(Config::TOSPUR_IMAGE_TABLE,array(
"image_type" => $item['type'], "image_type" => $item['type'],
),array("id" => $id)); ),array("id" => $id));
$exists_photo_ids[] = $id; $exists_photo_ids[] = $id;
...@@ -171,9 +171,9 @@ class SecHandHouse extends Tospur_House{ ...@@ -171,9 +171,9 @@ class SecHandHouse extends Tospur_House{
$delete_photo_ids[] = $id; $delete_photo_ids[] = $id;
} }
$delete_photo_ids = implode(",",$delete_photo_ids); $delete_photo_ids = implode(",",$delete_photo_ids);
$wpdb->query("delete from ".Config::A_HOUSE_IMAGE_TABLE." where house_id = {$houseId} and image_id in ({$delete_photo_ids});"); DBManager::query("delete from ".Config::A_HOUSE_IMAGE_TABLE." where house_id = {$houseId} and image_id in ({$delete_photo_ids});");
$wpdb->delete(Config::A_HOUSE_RECOMMEND_TABLE,array("house_id" => $houseId)); DBManager::delete(Config::A_HOUSE_RECOMMEND_TABLE,array("house_id" => $houseId));
$result = InsertDao::addRecommend($houseId,$data); $result = InsertDao::addRecommend($houseId,$data);
if(!is_numeric($result)){ if(!is_numeric($result)){
return $result; return $result;
...@@ -184,7 +184,7 @@ class SecHandHouse extends Tospur_House{ ...@@ -184,7 +184,7 @@ class SecHandHouse extends Tospur_House{
return $result; return $result;
} }
$wpdb->query( DBManager::query(
$wpdb->prepare( $wpdb->prepare(
"DELETE FROM a_house_tag "DELETE FROM a_house_tag
WHERE tag_id in(select tag_id from (select tag_id,tt.type from a_house_tag as aht WHERE tag_id in(select tag_id from (select tag_id,tt.type from a_house_tag as aht
......
...@@ -28,7 +28,7 @@ class secHandHouseList extends WP_List_Table ...@@ -28,7 +28,7 @@ class secHandHouseList extends WP_List_Table
$select = $select." left join(select user_id as aus_id,house_id from a_house_user) ahu on th.id = ahu.house_id"; $select = $select." left join(select user_id as aus_id,house_id from a_house_user) ahu on th.id = ahu.house_id";
$where = $where." and aus_id in ".$consultantArray; $where = $where." and aus_id in ".$consultantArray;
} }
$result = $wpdb->get_results($select.$where); $result = DBManager::get_results($select.$where);
foreach ($result as $value) { foreach ($result as $value) {
$approvalParam = array( $approvalParam = array(
"allNum" => $value->allNum, "allNum" => $value->allNum,
...@@ -171,14 +171,14 @@ class secHandHouseList extends WP_List_Table ...@@ -171,14 +171,14 @@ class secHandHouseList extends WP_List_Table
$approval = null; $approval = null;
switch ($action) { switch ($action) {
case"agree": case"agree":
$approvalRes = $wpdb->get_results('select approval from tospur_house where id in ' . $string); $approvalRes = DBManager::get_results('select approval from tospur_house where id in ' . $string);
foreach ($approvalRes as $value) { foreach ($approvalRes as $value) {
if ($value->approval == -2) { if ($value->approval == -2) {
print_r("您审批的房源中含有未申请审批的房源,请重新选择"); print_r("您审批的房源中含有未申请审批的房源,请重新选择");
exit; exit;
} }
} }
$result = $wpdb->query('update tospur_house th SET th.status= th.approval where id in ' . $string); $result = DBManager::query('update tospur_house th SET th.status= th.approval where id in ' . $string);
$flag = 1; $flag = 1;
break; break;
case"goBack": case"goBack":
...@@ -189,7 +189,7 @@ class secHandHouseList extends WP_List_Table ...@@ -189,7 +189,7 @@ class secHandHouseList extends WP_List_Table
break; break;
} }
if ($flag == 1) { if ($flag == 1) {
$wpdb->query('update tospur_house th SET th.approval= -2 where id in ' . $string); DBManager::query('update tospur_house th SET th.approval= -2 where id in ' . $string);
} }
} }
} }
...@@ -198,7 +198,7 @@ class secHandHouseList extends WP_List_Table ...@@ -198,7 +198,7 @@ class secHandHouseList extends WP_List_Table
{ {
global $wpdb; global $wpdb;
$sql = "select status from tospur_house where id in" . $houseId; $sql = "select status from tospur_house where id in" . $houseId;
$res = $wpdb->get_results($sql); $res = DBManager::get_results($sql);
foreach ($res as $value) { foreach ($res as $value) {
if ($value->status == $changeStatus) { if ($value->status == $changeStatus) {
print_r("您申请的状态含有与原状态相同的房源,请重新选择"); print_r("您申请的状态含有与原状态相同的房源,请重新选择");
...@@ -231,7 +231,6 @@ class secHandHouseList extends WP_List_Table ...@@ -231,7 +231,6 @@ class secHandHouseList extends WP_List_Table
$id = $_REQUEST['sechandhouselist']; $id = $_REQUEST['sechandhouselist'];
$string = '(' . implode(',', array_map('intval', $id)) . ')'; $string = '(' . implode(',', array_map('intval', $id)) . ')';
$status = null; $status = null;
$flag = 0;
switch ($action) { switch ($action) {
case 'unCheck': case 'unCheck':
$res = $this->getCurrentStatus($string, 0); $res = $this->getCurrentStatus($string, 0);
...@@ -283,8 +282,7 @@ class secHandHouseList extends WP_List_Table ...@@ -283,8 +282,7 @@ class secHandHouseList extends WP_List_Table
$status = $res; $status = $res;
break; break;
} }
if($flag == 0) $result = DBManager::query($wpdb->prepare('update tospur_house SET status = 0 , approval=%d where id in ' . $string, $status));
$result = $wpdb->query($wpdb->prepare('update tospur_house SET approval=%d where id in ' . $string, $status));
} }
} }
...@@ -416,7 +414,7 @@ class secHandHouseList extends WP_List_Table ...@@ -416,7 +414,7 @@ class secHandHouseList extends WP_List_Table
$order = $_GET["order"]; $order = $_GET["order"];
$sql = $sql . " order by " . $orderby . " " . $order; $sql = $sql . " order by " . $orderby . " " . $order;
} }
$result = $wpdb->get_results($wpdb->prepare($sql, $params)); $result = DBManager::get_results($wpdb->prepare($sql, $params));
$data = array(); $data = array();
foreach ($result as $key => $value) { foreach ($result as $key => $value) {
$data[$key] = array( $data[$key] = array(
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
class CommissionDao{ class CommissionDao{
public static function insert_touspur_commission($params){ public static function insert_touspur_commission($params){
global $wpdb; global $wpdb;
$wpdb->insert(Config::TOSPUR_COMMISSION,$params); DBManager::insert(Config::TOSPUR_COMMISSION,$params);
if($wpdb->insert_id){ if($wpdb->insert_id){
return $wpdb->insert_id; return $wpdb->insert_id;
}else{ }else{
...@@ -12,7 +12,7 @@ class CommissionDao{ ...@@ -12,7 +12,7 @@ class CommissionDao{
public static function insert_commission_log($params){ public static function insert_commission_log($params){
global $wpdb; global $wpdb;
$wpdb->insert(Config::TOSPUR_COMMISSION_LOG,$params); DBManager::insert(Config::TOSPUR_COMMISSION_LOG,$params);
if($wpdb->insert_id){ if($wpdb->insert_id){
return $wpdb->insert_id; return $wpdb->insert_id;
}else{ }else{
...@@ -26,16 +26,15 @@ class CommissionDao{ ...@@ -26,16 +26,15 @@ class CommissionDao{
left join (SELECT tct.id,imageUrl,tct.name,ton.name as branchName from ".Config::TOSPUR_CONSULTANT." tct left join (SELECT tct.id,imageUrl,tct.name,ton.name as branchName from ".Config::TOSPUR_CONSULTANT." tct
left JOIN ".Config::TOSPUR_ORGANIZATION_TABLE." ton on ton.id = tct.subsidiaryId) tc left JOIN ".Config::TOSPUR_ORGANIZATION_TABLE." ton on ton.id = tct.subsidiaryId) tc
on tcom.consultantId = tc.id where tcom.contractId = %d order by ioType;"; on tcom.consultantId = tc.id where tcom.contractId = %d order by ioType;";
$result = $wpdb->get_results($wpdb->prepare($sql,$contractId)); $result = DBManager::get_results($wpdb->prepare($sql,$contractId));
return $result; return $result;
} }
public static function search_commission_log($commissionIds){ public static function search_commission_log($commissionIds){
global $wpdb;
$sql = " SELECT tcl.id,time,paid,ioType from tospur_commission_log tcl $sql = " SELECT tcl.id,time,paid,ioType from tospur_commission_log tcl
left join tospur_commission tc on tc.id = tcl.commissionId left join tospur_commission tc on tc.id = tcl.commissionId
where tcl.commissionId in (".$commissionIds.");"; where tcl.commissionId in (".$commissionIds.");";
$result = $wpdb->get_results($sql); $result =DBManager::get_results($sql);
return $result; return $result;
} }
...@@ -43,7 +42,7 @@ class CommissionDao{ ...@@ -43,7 +42,7 @@ class CommissionDao{
global $wpdb; global $wpdb;
$sql = "select id,accounts,type,mtime from ".Config::TOSPUR_COMMISSION." $sql = "select id,accounts,type,mtime from ".Config::TOSPUR_COMMISSION."
where contractId = %d"; where contractId = %d";
$result = $wpdb->get_results($wpdb->prepare($sql,$contractId)); $result = DBManager::get_results($wpdb->prepare($sql,$contractId));
return $result; return $result;
} }
} }
...@@ -3,16 +3,17 @@ ...@@ -3,16 +3,17 @@
class ContractDao { class ContractDao {
public static function insert($params){ public static function insert($params){
global $wpdb; global $wpdb;
$wpdb->insert(Config::TOSPUR_CONTRACT,$params); DBManager::insert(Config::TOSPUR_CONTRACT,$params);
if($wpdb->last_error){ if($wpdb->last_error){
return $wpdb->last_error; return $wpdb->last_error;
} }
return $wpdb->insert_id; return $wpdb->insert_id;
} }
public static function setContractId($id,$contractId){ public static function setContractId($id,$contractId){
global $wpdb; global $wpdb;
$result = $wpdb->update(Config::TOSPUR_CONTRACT,array( $result = DBManager::update(Config::TOSPUR_CONTRACT,array(
"contractId" => $contractId "contractId" => $contractId
),array( ),array(
"id" => $id "id" => $id
...@@ -26,7 +27,7 @@ class ContractDao { ...@@ -26,7 +27,7 @@ class ContractDao {
public static function update($id,$params){ public static function update($id,$params){
global $wpdb; global $wpdb;
$result = $wpdb->update(Config::TOSPUR_CONTRACT,$params,array( $result =DBManager::update(Config::TOSPUR_CONTRACT,$params,array(
"id" => $id "id" => $id
)); ));
if($wpdb->last_error) if($wpdb->last_error)
...@@ -39,7 +40,7 @@ class ContractDao { ...@@ -39,7 +40,7 @@ class ContractDao {
$sql = "select tc.*,th.address from ".Config::TOSPUR_CONTRACT." tc $sql = "select tc.*,th.address from ".Config::TOSPUR_CONTRACT." tc
left join ".Config::TOSPUR_HOUSE_TABLE." th on tc.houseId = th.id left join ".Config::TOSPUR_HOUSE_TABLE." th on tc.houseId = th.id
where tc.id = %d;"; where tc.id = %d;";
$result = $wpdb->get_row($wpdb->prepare($sql,$id)); $result =DBManager::get_row($wpdb->prepare($sql,$id));
if($result){ if($result){
return $result; return $result;
}else{ }else{
...@@ -49,7 +50,7 @@ class ContractDao { ...@@ -49,7 +50,7 @@ class ContractDao {
public static function insert_a_contract_image($params){ public static function insert_a_contract_image($params){
global $wpdb; global $wpdb;
$wpdb->insert(Config::A_CONTRACT_IMAGE_TABLE,$params); DBManager::insert(Config::A_CONTRACT_IMAGE_TABLE,$params);
if($wpdb->last_error){ if($wpdb->last_error){
return $wpdb->last_error; return $wpdb->last_error;
} }
...@@ -110,7 +111,7 @@ class ContractDao { ...@@ -110,7 +111,7 @@ class ContractDao {
$sql = "select ti.id,ti.path from a_contract_image aci $sql = "select ti.id,ti.path from a_contract_image aci
left join tospur_contract tc on tc.id = aci.contract_id left join tospur_contract tc on tc.id = aci.contract_id
left join tospur_image ti on aci.image_id = ti.id where aci.contract_id = %d;"; left join tospur_image ti on aci.image_id = ti.id where aci.contract_id = %d;";
$result = $wpdb->get_results($wpdb->prepare($sql,$id)); $result =DBManager::get_results($wpdb->prepare($sql,$id));
if($wpdb->last_error){ if($wpdb->last_error){
return $wpdb->last_error; return $wpdb->last_error;
} }
...@@ -120,7 +121,7 @@ class ContractDao { ...@@ -120,7 +121,7 @@ class ContractDao {
public static function searchImgPath($id){ public static function searchImgPath($id){
global $wpdb; global $wpdb;
$sql = "select path from ".Config::TOSPUR_IMAGE_TABLE." where id in ({$id})"; $sql = "select path from ".Config::TOSPUR_IMAGE_TABLE." where id in ({$id})";
$results = $wpdb->get_results($sql); $results =DBManager::get_results($sql);
if($wpdb->last_error){ if($wpdb->last_error){
return $wpdb->last_error; return $wpdb->last_error;
} }
......
...@@ -28,7 +28,7 @@ class CustomerTrackingDao ...@@ -28,7 +28,7 @@ class CustomerTrackingDao
'description' => $request['description'], 'description' => $request['description'],
'origin' => $origin 'origin' => $origin
); );
$result = $wpdb->insert(Config::TOSPUR_CUSTOMER_TRACKING_TABLE, $array); $result = DBManager::insert(Config::TOSPUR_CUSTOMER_TRACKING_TABLE, $array);
if ($result) { if ($result) {
return $wpdb->insert_id; return $wpdb->insert_id;
} else { } else {
...@@ -41,20 +41,18 @@ class CustomerTrackingDao ...@@ -41,20 +41,18 @@ class CustomerTrackingDao
public static function search($house_id, $origin) public static function search($house_id, $origin)
{ {
global $wpdb;
$sql = 'SELECT tct.*,ts.status_name,tc.name FROM ' . Config::TOSPUR_CUSTOMER_TRACKING_TABLE . ' tct' . $sql = 'SELECT tct.*,ts.status_name,tc.name FROM ' . Config::TOSPUR_CUSTOMER_TRACKING_TABLE . ' tct' .
' left join (SELECT * FROM ' . Config::TOSPUR_STATUS_TABLE . ' where status_type = 3) as ts on tct.status_type = ts.status_id' . ' left join (SELECT * FROM ' . Config::TOSPUR_STATUS_TABLE . ' where status_type = 3) as ts on tct.status_type = ts.status_id' .
' left join ' . Config::TOSPUR_CONSULTANT . ' tc on tct.consultant_id = tc.id' . ' left join ' . Config::TOSPUR_CONSULTANT . ' tc on tct.consultant_id = tc.id' .
' where tct.house_id = ' . $house_id . ' and tct.origin = ' . $origin; ' where tct.house_id = ' . $house_id . ' and tct.origin = ' . $origin;
$result = $wpdb->get_results($sql); $result = DBManager::get_results($sql);
return $result; return $result;
} }
public static function search_status() public static function search_status()
{ {
global $wpdb;
$sql = 'SELECT * FROM ' . Config::TOSPUR_STATUS_TABLE . ' where status_type = 3'; $sql = 'SELECT * FROM ' . Config::TOSPUR_STATUS_TABLE . ' where status_type = 3';
return $wpdb->get_results($sql); return DBManager::get_results($sql);
} }
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
class HouseDao { class HouseDao {
public static function updateStatus($status,$houseId){ public static function updateStatus($status,$houseId){
global $wpdb; global $wpdb;
$result = $wpdb->update(Config::TOSPUR_HOUSE_TABLE,array( $result = DBManager::update(Config::TOSPUR_HOUSE_TABLE,array(
'status' => $status 'status' => $status
),array( ),array(
'id' => $houseId 'id' => $houseId
...@@ -15,7 +15,7 @@ class HouseDao { ...@@ -15,7 +15,7 @@ class HouseDao {
public static function checkHouseStatus($houseId){ public static function checkHouseStatus($houseId){
global $wpdb; global $wpdb;
$result = $wpdb->get_row(Config::TOSPUR_HOUSE_TABLE,array( $result = DBManager::get_row(Config::TOSPUR_HOUSE_TABLE,array(
'id' => $houseId 'id' => $houseId
)); ));
if($wpdb->last_error) if($wpdb->last_error)
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
class InsertDao{ class InsertDao{
public static function insert_tospur_house($params){ public static function insert_tospur_house($params){
global $wpdb; global $wpdb;
$wpdb->insert(Config::TOSPUR_HOUSE_TABLE, $params); DBManager::insert(Config::TOSPUR_HOUSE_TABLE, $params);
if($wpdb->last_error){ if($wpdb->last_error){
return $wpdb->last_error; return $wpdb->last_error;
} }
...@@ -15,7 +15,6 @@ class InsertDao{ ...@@ -15,7 +15,6 @@ class InsertDao{
} }
public static function setHouseNumber($houseId,$houseType,$cityId){ public static function setHouseNumber($houseId,$houseType,$cityId){
global $wpdb;
switch($houseType){ switch($houseType){
case 0: case 0:
$prefix = "xf"; $prefix = "xf";
...@@ -28,7 +27,7 @@ class InsertDao{ ...@@ -28,7 +27,7 @@ class InsertDao{
break; break;
} }
$house_number = $prefix.str_pad($cityId,4,'0',STR_PAD_LEFT).str_pad($houseId,8,'0',STR_PAD_LEFT); $house_number = $prefix.str_pad($cityId,4,'0',STR_PAD_LEFT).str_pad($houseId,8,'0',STR_PAD_LEFT);
return $wpdb->update(Config::TOSPUR_HOUSE_TABLE, return DBManager::update(Config::TOSPUR_HOUSE_TABLE,
array( array(
'house_number' => $house_number 'house_number' => $house_number
), ),
...@@ -40,7 +39,7 @@ class InsertDao{ ...@@ -40,7 +39,7 @@ class InsertDao{
public static function insert_tospur_image($params){ public static function insert_tospur_image($params){
global $wpdb; global $wpdb;
$wpdb->insert(Config::TOSPUR_IMAGE_TABLE, $params); DBManager::insert(Config::TOSPUR_IMAGE_TABLE, $params);
if($wpdb->last_error){ if($wpdb->last_error){
return $wpdb->last_error; return $wpdb->last_error;
} }
...@@ -49,7 +48,7 @@ class InsertDao{ ...@@ -49,7 +48,7 @@ class InsertDao{
} }
public static function insert_a_district_area($params){ public static function insert_a_district_area($params){
global $wpdb; global $wpdb;
$wpdb->insert(Config::A_DISTRICT_AREA_TABLE, $params); DBManager::insert(Config::A_DISTRICT_AREA_TABLE, $params);
if($wpdb->last_error){ if($wpdb->last_error){
return $wpdb->last_error; return $wpdb->last_error;
} }
...@@ -58,7 +57,7 @@ class InsertDao{ ...@@ -58,7 +57,7 @@ class InsertDao{
public static function insert_a_house_image($params){ public static function insert_a_house_image($params){
global $wpdb; global $wpdb;
$wpdb->insert(Config::A_HOUSE_IMAGE_TABLE, $params); DBManager::insert(Config::A_HOUSE_IMAGE_TABLE, $params);
if($wpdb->last_error){ if($wpdb->last_error){
return $wpdb->last_error; return $wpdb->last_error;
} }
...@@ -67,7 +66,7 @@ class InsertDao{ ...@@ -67,7 +66,7 @@ class InsertDao{
public static function insert_a_house_recommend($params){ public static function insert_a_house_recommend($params){
global $wpdb; global $wpdb;
$wpdb->insert(Config::A_HOUSE_RECOMMEND_TABLE, $params); DBManager::insert(Config::A_HOUSE_RECOMMEND_TABLE, $params);
if($wpdb->last_error){ if($wpdb->last_error){
return $wpdb->last_error; return $wpdb->last_error;
} }
...@@ -76,7 +75,7 @@ class InsertDao{ ...@@ -76,7 +75,7 @@ class InsertDao{
public static function insert_a_house_user($params){ public static function insert_a_house_user($params){
global $wpdb; global $wpdb;
$wpdb->insert(Config::A_HOUSE_USER_TABLE, $params); DBManager::insert(Config::A_HOUSE_USER_TABLE, $params);
if($wpdb->last_error){ if($wpdb->last_error){
return $wpdb->last_error; return $wpdb->last_error;
} }
...@@ -123,7 +122,7 @@ class InsertDao{ ...@@ -123,7 +122,7 @@ class InsertDao{
$imagePath = get_home_path().$url; $imagePath = get_home_path().$url;
Image::makeImage($uploadFileName,$imagePath); Image::makeImage($uploadFileName,$imagePath);
//插入图片表 //插入图片表
$wpdb->insert('tospur_image', $insert_image_array); DBManager::insert('tospur_image', $insert_image_array);
if ($wpdb->last_error) { if ($wpdb->last_error) {
return $wpdb->last_error; return $wpdb->last_error;
} }
...@@ -142,7 +141,7 @@ class InsertDao{ ...@@ -142,7 +141,7 @@ class InsertDao{
"house_area" => $data["$key"]["housearea"], "house_area" => $data["$key"]["housearea"],
"image_id" => $imgid "image_id" => $imgid
); );
$wpdb->insert(Config::A_DISTRICT_AREA_TABLE, $houseTypeArea); DBManager::insert(Config::A_DISTRICT_AREA_TABLE, $houseTypeArea);
if ($wpdb->last_error) { if ($wpdb->last_error) {
return $wpdb->last_error; return $wpdb->last_error;
} }
...@@ -152,7 +151,7 @@ class InsertDao{ ...@@ -152,7 +151,7 @@ class InsertDao{
'house_id' => $houseId, 'house_id' => $houseId,
'image_id' => $imgid, 'image_id' => $imgid,
); );
$wpdb->insert(Config::A_HOUSE_IMAGE_TABLE, $house_img_array); DBManager::insert(Config::A_HOUSE_IMAGE_TABLE, $house_img_array);
if ($wpdb->last_error) { if ($wpdb->last_error) {
return $wpdb->last_error; return $wpdb->last_error;
} }
...@@ -162,7 +161,7 @@ class InsertDao{ ...@@ -162,7 +161,7 @@ class InsertDao{
} }
} }
} }
$wpdb->update(Config::TOSPUR_HOUSE_TABLE,array("frontCover_id"=>$frontCover),array("id"=>$houseId)); DBManager::update(Config::TOSPUR_HOUSE_TABLE,array("frontCover_id"=>$frontCover),array("id"=>$houseId));
if ($wpdb->last_error) { if ($wpdb->last_error) {
return $wpdb->last_error; return $wpdb->last_error;
} }
...@@ -178,7 +177,7 @@ class InsertDao{ ...@@ -178,7 +177,7 @@ class InsertDao{
"house_id" => $houseId, "house_id" => $houseId,
"recommend_id" =>$value "recommend_id" =>$value
); );
$wpdb->insert(Config::A_HOUSE_RECOMMEND_TABLE, $a_house_recommendArray); DBManager::insert(Config::A_HOUSE_RECOMMEND_TABLE, $a_house_recommendArray);
if( $wpdb->last_error){ if( $wpdb->last_error){
return $wpdb->last_error; return $wpdb->last_error;
} }
...@@ -190,7 +189,7 @@ class InsertDao{ ...@@ -190,7 +189,7 @@ class InsertDao{
public static function addRecConsultant($houseId, $consultant){ public static function addRecConsultant($houseId, $consultant){
global $wpdb; global $wpdb;
if($consultant){ if($consultant){
$wpdb->delete(Config::A_HOUSE_USER_TABLE,array("house_id" => $houseId)); DBManager::delete(Config::A_HOUSE_USER_TABLE,array("house_id" => $houseId));
//插入推荐置业顾问user_id与新房id到关联表a_house_recommend //插入推荐置业顾问user_id与新房id到关联表a_house_recommend
foreach($consultant as $val){ foreach($consultant as $val){
$a_house_userArray = array( $a_house_userArray = array(
...@@ -198,13 +197,13 @@ class InsertDao{ ...@@ -198,13 +197,13 @@ class InsertDao{
"house_id" => $houseId, "house_id" => $houseId,
"user_type" => 1 "user_type" => 1
); );
$wpdb->replace(Config::A_HOUSE_USER_TABLE,$a_house_userArray); DBManager::replace(Config::A_HOUSE_USER_TABLE,$a_house_userArray);
if( $wpdb->last_error){ if( $wpdb->last_error){
return $wpdb->last_error; return $wpdb->last_error;
} }
} }
$res = $wpdb->get_row("select subsidiaryId from ".Config::TOSPUR_CONSULTANT." where id =".$consultant[0]); $res =DBManager::get_row("select subsidiaryId from ".Config::TOSPUR_CONSULTANT." where id =".$consultant[0]);
$wpdb->update(Config::TOSPUR_HOUSE_TABLE,array("organizationId"=>$res->subsidiaryId),array("id"=>$houseId)); DBManager::update(Config::TOSPUR_HOUSE_TABLE,array("organizationId"=>$res->subsidiaryId),array("id"=>$houseId));
if( $wpdb->last_error){ if( $wpdb->last_error){
return $wpdb->last_error; return $wpdb->last_error;
} }
...@@ -220,7 +219,7 @@ class InsertDao{ ...@@ -220,7 +219,7 @@ class InsertDao{
"house_id" => $houseId, "house_id" => $houseId,
"tag_id" =>$val "tag_id" =>$val
); );
$wpdb->insert(Config::A_HOUSE_TAG_TABLE,$a_house_feature); DBManager::insert(Config::A_HOUSE_TAG_TABLE,$a_house_feature);
if( $wpdb->last_error){ if( $wpdb->last_error){
return $wpdb->last_error; return $wpdb->last_error;
} }
...@@ -233,7 +232,7 @@ class InsertDao{ ...@@ -233,7 +232,7 @@ class InsertDao{
public static function addHouseTag($house_id, $houseTag) public static function addHouseTag($house_id, $houseTag)
{ {
global $wpdb; global $wpdb;
$wpdb->query( DBManager::query(
$wpdb->prepare("DELETE FROM " . Config::A_HOUSE_TAG_TABLE . $wpdb->prepare("DELETE FROM " . Config::A_HOUSE_TAG_TABLE .
" WHERE tag_id in(select tag_id from (select tag_id,tt.type from " . Config::A_HOUSE_TAG_TABLE . " as aht" . " WHERE tag_id in(select tag_id from (select tag_id,tt.type from " . Config::A_HOUSE_TAG_TABLE . " as aht" .
" left JOIN " . Config::TOSPUR_TAG_TABLE . " tt on aht.tag_id = tt.id) as a" . " left JOIN " . Config::TOSPUR_TAG_TABLE . " tt on aht.tag_id = tt.id) as a" .
...@@ -248,7 +247,7 @@ class InsertDao{ ...@@ -248,7 +247,7 @@ class InsertDao{
"house_id" => $house_id, "house_id" => $house_id,
"tag_id" => $val "tag_id" => $val
); );
$wpdb->insert(Config::A_HOUSE_TAG_TABLE, $a_house_tag); DBManager::insert(Config::A_HOUSE_TAG_TABLE, $a_house_tag);
if( $wpdb->last_error){ if( $wpdb->last_error){
return $wpdb->last_error; return $wpdb->last_error;
} }
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
class QuotaDao { class QuotaDao {
public static function replace($year,$month,$consultantId,$quota){ public static function replace($year,$month,$consultantId,$quota){
global $wpdb; global $wpdb;
$result = $wpdb->replace(Config::TOSPUR_QUOTA_TABLE,array( $result = DBManager::replace(Config::TOSPUR_QUOTA_TABLE,array(
"year" => $year, "year" => $year,
"month" => $month, "month" => $month,
"consultantId" => $consultantId, "consultantId" => $consultantId,
......
...@@ -29,7 +29,7 @@ class SearchDao ...@@ -29,7 +29,7 @@ class SearchDao
$params[] = $districtId; $params[] = $districtId;
$groupBy = ""; $groupBy = "";
} }
$result = $wpdb->get_results($wpdb->prepare('select ' . $selectName . ' from ' . Config::DIC_CITY_TABLE . $where . $groupBy, $params)); $result = DBManager::get_results($wpdb->prepare('select ' . $selectName . ' from ' . Config::DIC_CITY_TABLE . $where . $groupBy, $params));
return $result; return $result;
} }
...@@ -45,7 +45,7 @@ class SearchDao ...@@ -45,7 +45,7 @@ class SearchDao
if (isset($_GET['cityId'])) { if (isset($_GET['cityId'])) {
$where .= " and cityId = %d"; $where .= " and cityId = %d";
} }
$result = $wpdb->get_results($wpdb->prepare('select id,priceValue as value from ' . Config::DIC_AREA_TABLE . $where, $cityId)); $result = DBManager::get_results($wpdb->prepare('select id,priceValue as value from ' . Config::DIC_AREA_TABLE . $where, $cityId));
return $result; return $result;
} }
...@@ -57,7 +57,7 @@ class SearchDao ...@@ -57,7 +57,7 @@ class SearchDao
public static function searchBuildProperty() public static function searchBuildProperty()
{ {
global $wpdb; global $wpdb;
$result = $wpdb->get_results('select value as id,literal as value from ' . Config::DIC_BUILDPROPERTY_TABLE); $result = DBManager::get_results('select value as id,literal as value from ' . Config::DIC_BUILDPROPERTY_TABLE);
return $result; return $result;
} }
...@@ -68,8 +68,7 @@ class SearchDao ...@@ -68,8 +68,7 @@ class SearchDao
public static function searchRoom() public static function searchRoom()
{ {
global $wpdb; $result = DBManager::get_results('select value as id,literal as value from ' . Config::DIC_ROOM_TABLE);
$result = $wpdb->get_results('select value as id,literal as value from ' . Config::DIC_ROOM_TABLE);
return $result; return $result;
} }
...@@ -85,7 +84,7 @@ class SearchDao ...@@ -85,7 +84,7 @@ class SearchDao
if (isset($_GET['cityId'])) { if (isset($_GET['cityId'])) {
$where .= " and cityId = %d"; $where .= " and cityId = %d";
} }
$result = $wpdb->get_results($wpdb->prepare('select id,priceValue as value from ' . Config::DIC_UNITPRICERANGE_TABLE . $where, $cityId)); $result = DBManager::get_results($wpdb->prepare('select id,priceValue as value from ' . Config::DIC_UNITPRICERANGE_TABLE . $where, $cityId));
return $result; return $result;
} }
...@@ -101,7 +100,7 @@ class SearchDao ...@@ -101,7 +100,7 @@ class SearchDao
if ($cityId) { if ($cityId) {
$where .= " and cityId = " . $cityId; $where .= " and cityId = " . $cityId;
} }
$result = $wpdb->get_results($wpdb->prepare('select id,priceValue as value from ' . Config::DIC_TOTALPRICE_TABLE . $where, $cityId)); $result = DBManager::get_results($wpdb->prepare('select id,priceValue as value from ' . Config::DIC_TOTALPRICE_TABLE . $where, $cityId));
return $result; return $result;
} }
...@@ -117,7 +116,7 @@ class SearchDao ...@@ -117,7 +116,7 @@ class SearchDao
if ($cityId) { if ($cityId) {
$where .= " and cityId = " . $cityId; $where .= " and cityId = " . $cityId;
} }
$result = $wpdb->get_results($wpdb->prepare('select id,priceValue as value from ' . Config::DIC_RENTALPRICE_TABLE . $where, $cityId)); $result = DBManager::get_results($wpdb->prepare('select id,priceValue as value from ' . Config::DIC_RENTALPRICE_TABLE . $where, $cityId));
return $result; return $result;
} }
...@@ -133,14 +132,14 @@ class SearchDao ...@@ -133,14 +132,14 @@ class SearchDao
if ($parentId != NULL) { if ($parentId != NULL) {
$where .= " and ParentId = %d"; $where .= " and ParentId = %d";
} }
$result = $wpdb->get_results($wpdb->prepare('select * from ' . Config::TOSPUR_ORGANIZATION_TABLE . $where, $parentId)); $result = DBManager::get_results($wpdb->prepare('select * from ' . Config::TOSPUR_ORGANIZATION_TABLE . $where, $parentId));
return $result; return $result;
} }
public static function getCityNameWithId($cityId) public static function getCityNameWithId($cityId)
{ {
global $wpdb; global $wpdb;
$result = $wpdb->get_var($wpdb->prepare("select cityName from " . Config::DIC_CITY_TABLE . " where cityId = %d", $cityId)); $result = DBManager::get_var($wpdb->prepare("select cityName from " . Config::DIC_CITY_TABLE . " where cityId = %d", $cityId));
if ($result) { if ($result) {
return $result; return $result;
} else { } else {
...@@ -273,7 +272,7 @@ class SearchDao ...@@ -273,7 +272,7 @@ class SearchDao
$params[] = $array['index']; $params[] = $array['index'];
$sql = $sql . " limit %d,10"; $sql = $sql . " limit %d,10";
} }
$result = $wpdb->get_results($wpdb->prepare($sql, $params)); $result = DBManager::get_results($wpdb->prepare($sql, $params));
return $result; return $result;
} }
...@@ -285,7 +284,7 @@ class SearchDao ...@@ -285,7 +284,7 @@ class SearchDao
public static function searchPhotoType() public static function searchPhotoType()
{ {
global $wpdb; global $wpdb;
$result = $wpdb->get_results('select id,photo_name as value from ' . Config::DIC_PHOTOTYPE_TABLE); $result = DBManager::get_results('select id,photo_name as value from ' . Config::DIC_PHOTOTYPE_TABLE);
return $result; return $result;
} }
...@@ -307,7 +306,7 @@ class SearchDao ...@@ -307,7 +306,7 @@ class SearchDao
$params[] = '%'.$consultantName.'%'; $params[] = '%'.$consultantName.'%';
$sql = $sql." and tc.name like %s"; $sql = $sql." and tc.name like %s";
} }
$result = $wpdb->get_results($wpdb->prepare($sql,$params)); $result = DBManager::get_results($wpdb->prepare($sql,$params));
return $result; return $result;
} }
...@@ -335,15 +334,14 @@ class SearchDao ...@@ -335,15 +334,14 @@ class SearchDao
global $wpdb; global $wpdb;
$featureSql ="select tag_id,name from ".Config::A_HOUSE_TAG_TABLE." aht $featureSql ="select tag_id,name from ".Config::A_HOUSE_TAG_TABLE." aht
LEFT JOIN (select id as tid,name ,type from ".Config::TOSPUR_TAG_TABLE.") tt on aht.tag_id = tt.tid where aht.house_id = %d and type = 1"; LEFT JOIN (select id as tid,name ,type from ".Config::TOSPUR_TAG_TABLE.") tt on aht.tag_id = tt.tid where aht.house_id = %d and type = 1";
$feature = $wpdb->get_results($wpdb->prepare($featureSql,$hid)); $feature = DBManager::get_results($wpdb->prepare($featureSql,$hid));
return $feature; return $feature;
} }
public static function searchFeature() public static function searchFeature()
{ {
global $wpdb;
$sql = 'select id,name as value from '.Config::TOSPUR_TAG_TABLE.' where type = 1;'; $sql = 'select id,name as value from '.Config::TOSPUR_TAG_TABLE.' where type = 1;';
return $wpdb->get_results($sql); return DBManager::get_results($sql);
} }
public static function ajax_searchTagOrFeature() public static function ajax_searchTagOrFeature()
...@@ -353,9 +351,8 @@ class SearchDao ...@@ -353,9 +351,8 @@ class SearchDao
public static function searchTagOrFeature($type) public static function searchTagOrFeature($type)
{ {
global $wpdb;
$sql = 'select id,name as value from ' . Config::TOSPUR_TAG_TABLE . ' where type = ' . $type; $sql = 'select id,name as value from ' . Config::TOSPUR_TAG_TABLE . ' where type = ' . $type;
return $wpdb->get_results($sql); return DBManager::get_results($sql);
} }
public static function getDetailInfo($hid,$type = NULL){ public static function getDetailInfo($hid,$type = NULL){
...@@ -364,7 +361,7 @@ class SearchDao ...@@ -364,7 +361,7 @@ class SearchDao
left JOIN ".Config::DIC_ROOM_TABLE." dr on th.room_id = dr.id left JOIN ".Config::DIC_ROOM_TABLE." dr on th.room_id = dr.id
left JOIN ".Config::DIC_BUILDPROPERTY_TABLE." db on th.buildproperty_id = db.value left JOIN ".Config::DIC_BUILDPROPERTY_TABLE." db on th.buildproperty_id = db.value
where th.id = %d"; where th.id = %d";
$result = $wpdb->get_row($wpdb->prepare($sql,$hid)); $result = DBManager::get_row($wpdb->prepare($sql,$hid));
$context = array(); $context = array();
$context['result'] = $result; $context['result'] = $result;
$houseType = $result->house_type; $houseType = $result->house_type;
...@@ -376,7 +373,7 @@ class SearchDao ...@@ -376,7 +373,7 @@ class SearchDao
LEFT JOIN ".Config::DIC_BUILDPROPERTY_TABLE." db on db.value = ada.buildproperty_id LEFT JOIN ".Config::DIC_BUILDPROPERTY_TABLE." db on db.value = ada.buildproperty_id
LEFT JOIN ".Config::TOSPUR_IMAGE_TABLE." ti on ti.id = ada.image_id LEFT JOIN ".Config::TOSPUR_IMAGE_TABLE." ti on ti.id = ada.image_id
where ada.house_id = %d"; where ada.house_id = %d";
$mainImage = $wpdb->get_results($wpdb->prepare($mainImagesSql,$hid)); $mainImage = DBManager::get_results($wpdb->prepare($mainImagesSql,$hid));
foreach($mainImage as $key => $value){ foreach($mainImage as $key => $value){
$path = $value->path; $path = $value->path;
...@@ -400,7 +397,7 @@ class SearchDao ...@@ -400,7 +397,7 @@ class SearchDao
where th.id in(select recommend_id from ".Config::A_HOUSE_RECOMMEND_TABLE." where house_id = %d);"; where th.id in(select recommend_id from ".Config::A_HOUSE_RECOMMEND_TABLE." where house_id = %d);";
} }
$recommends = $wpdb->get_results($wpdb->prepare($recommendSql,$hid)); $recommends = DBManager::get_results($wpdb->prepare($recommendSql,$hid));
foreach($recommends as $key => $value){ foreach($recommends as $key => $value){
$value->path = Image::getImage($value->path,'small'); $value->path = Image::getImage($value->path,'small');
} }
...@@ -411,7 +408,7 @@ class SearchDao ...@@ -411,7 +408,7 @@ class SearchDao
from ".Config::TOSPUR_CONSULTANT_SCORE_TABLE." from ".Config::TOSPUR_CONSULTANT_SCORE_TABLE."
where valid=1 group by consultant_id) s on c.id = s.consultant_id where valid=1 group by consultant_id) s on c.id = s.consultant_id
where id in(select user_id from ".Config::A_HOUSE_USER_TABLE." where user_type = 1 and house_id = %d) limit {$consultantLimit};"; where id in(select user_id from ".Config::A_HOUSE_USER_TABLE." where user_type = 1 and house_id = %d) limit {$consultantLimit};";
$consultant = $wpdb->get_results($wpdb->prepare($consultantSql,$hid)); $consultant = DBManager::get_results($wpdb->prepare($consultantSql,$hid));
$context['consultant'] = $consultant; $context['consultant'] = $consultant;
if($type == 'edit'){ if($type == 'edit'){
...@@ -424,7 +421,7 @@ class SearchDao ...@@ -424,7 +421,7 @@ class SearchDao
WHERE ahi.house_id = %d order by image_type;'; WHERE ahi.house_id = %d order by image_type;';
} }
$images = $wpdb->get_results($wpdb->prepare($imagesSql,$hid,$hid)); $images = DBManager::get_results($wpdb->prepare($imagesSql,$hid,$hid));
foreach($images as $key => $value){ foreach($images as $key => $value){
$path = $value->path; $path = $value->path;
$value->path = Image::getImage($path,'big'); $value->path = Image::getImage($path,'big');
...@@ -440,7 +437,7 @@ class SearchDao ...@@ -440,7 +437,7 @@ class SearchDao
$sql = "select tt.name from ".Config::A_HOUSE_TAG_TABLE." aht $sql = "select tt.name from ".Config::A_HOUSE_TAG_TABLE." aht
LEFT JOIN ".Config::TOSPUR_TAG_TABLE." tt on aht.tag_id = tt.id LEFT JOIN ".Config::TOSPUR_TAG_TABLE." tt on aht.tag_id = tt.id
where aht.house_id = %d and type = 0;"; where aht.house_id = %d and type = 0;";
$results = $wpdb->get_results($wpdb->prepare($sql,$houseId)); $results = DBManager::get_results($wpdb->prepare($sql,$houseId));
$tags = array(); $tags = array();
foreach($results as $item){ foreach($results as $item){
$tags[] =$item->name; $tags[] =$item->name;
...@@ -451,7 +448,7 @@ class SearchDao ...@@ -451,7 +448,7 @@ class SearchDao
public static function searchStatusType($statusType){ public static function searchStatusType($statusType){
global $wpdb; global $wpdb;
$sql="select status_id as id,status_name as value from ".Config::TOSPUR_STATUS_TABLE." where status_type = %d"; $sql="select status_id as id,status_name as value from ".Config::TOSPUR_STATUS_TABLE." where status_type = %d";
$results = $wpdb->get_results($wpdb->prepare($sql,$statusType)); $results = DBManager::get_results($wpdb->prepare($sql,$statusType));
return $results; return $results;
} }
...@@ -463,7 +460,7 @@ class SearchDao ...@@ -463,7 +460,7 @@ class SearchDao
$params[] = $type; $params[] = $type;
$featureSql ="select tag_id,name from a_house_tag aht $featureSql ="select tag_id,name from a_house_tag aht
LEFT JOIN (select id as tid,name ,type from ".Config::TOSPUR_TAG_TABLE.") tt on aht.tag_id = tt.tid where aht.house_id = %d and tt.type = %d"; LEFT JOIN (select id as tid,name ,type from ".Config::TOSPUR_TAG_TABLE.") tt on aht.tag_id = tt.tid where aht.house_id = %d and tt.type = %d";
$feature = $wpdb->get_results($wpdb->prepare($featureSql,$params)); $feature = DBManager::get_results($wpdb->prepare($featureSql,$params));
return $feature; return $feature;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment