<?php

class HouseDao {
    public static function updateStatus($status,$houseId){
        global $wpdb;
        $result = DBManager::update(Config::TOSPUR_HOUSE_TABLE,array(
            'status' => $status
        ),array(
            'id' => $houseId
        ));
        if($wpdb->last_error)
            return $wpdb->last_error;
        return $result;
    }

    public static function checkHouseStatus($houseId){
        global $wpdb;
        $result = DBManager::get_row(Config::TOSPUR_HOUSE_TABLE,array(
            'id' => $houseId
        ));
        if($wpdb->last_error)
            return $wpdb->last_error;
        return $result;
    }

    public static function houseAllotConsultant($consultant_id, $house_ids)
    {
        if ($consultant_id) {
            foreach($house_ids as $id){
                $result = InsertDao::addRecConsultant($id,array($consultant_id));
            }
            echo '<script>alert("分配置业顾问成功");</script>';
        }
    }
}