<?php

class TospurDao
{
    public static function insert_view_house($house_id, $user_id, $date, $time, $consultant_id)
    {
        $insert_view_house_array = array(
            'house_id' => $house_id,
            'user_id' => $user_id,
            'date' => $date,
            'time' => $time,
            'consultant_id' => $consultant_id,
            'handle' => 0
        );
        global $wpdb;
        $result = $wpdb->insert('view_house', $insert_view_house_array);
        return $result;
    }

    public static function search_view_house_by_user_id($user_id)
    {
        global $wpdb;
        $sql = "select v.house_id,v.date,v.time,v.consultant_id,v.handle from view_house v where user_id = " . $user_id . " order by v.date desc";
        return $wpdb->get_results($sql);
    }

    public static function search_view_house_by_consultant_id($consultant_id)
    {
        global $wpdb;
        $sql = "select v.house_id,v.user_id,v.date,v.time,v.handle from view_house v where consultant_id = " . $consultant_id . " order by v.date desc";
        return $wpdb->get_results($sql);
    }


}

?>