示例#1
0
 public function get_page_data($page_size, $offset = 0, $kw = '', $conditions = NULL)
 {
     $this->load->helper('housesql');
     $sub_where = to_where_by_raw_conditions($this, $conditions);
     //to_where_str($this, $conditions)
     if (isset($kw) && !empty($kw)) {
         $kw = $this->db->escape_like_str($kw);
         $sub_sql = "select * from tab_sellhouse where {$sub_where} and (title like '%{$kw}%' or community like '%{$kw}%') order by update_time desc limit {$offset},{$page_size}";
     } else {
         $sub_sql = "select * from tab_sellhouse where {$sub_where} order by update_time desc limit {$offset},{$page_size}";
     }
     $select = to_select_str($this, array('*'), 'h.') . ', ' . to_select_str($this, array('true_name', 'contact_mobile'), 'u.');
     $sql = "select {$select} from ({$sub_sql}) h, tab_user u where h.uid = u.uid;";
     // print_r($sql);
     // print_r($this->db->escape($sql));
     return $this->db->query($sql)->result_array();
 }
示例#2
0
 public function test_to_select_str()
 {
     $this->load->database();
     $this->load->helper('housesql');
     $conditions = NULL;
     $sub_where = to_select_str($this, $conditions);
     print_r($sub_where);
     print_r("<br/>");
     $conditions = 'hid';
     $sub_where = to_select_str($this, $conditions);
     print_r($sub_where);
     print_r("<br/>");
     $conditions = array('hid');
     $sub_where = to_select_str($this, $conditions);
     print_r($sub_where);
     print_r("<br/>");
     $conditions = array('hid', 'title');
     $sub_where = to_select_str($this, $conditions);
     print_r($sub_where);
     print_r("<br/>");
     $conditions = NULL;
     $sub_where = to_select_str($this, $conditions, 'h.');
     print_r($sub_where);
     print_r("<br/>");
     $conditions = 'hid';
     $sub_where = to_select_str($this, $conditions, 'h.');
     print_r($sub_where);
     print_r("<br/>");
     $conditions = array('hid');
     $sub_where = to_select_str($this, $conditions, 'h.');
     print_r($sub_where);
     print_r("<br/>");
     $conditions = array('hid', 'title');
     $sub_where = to_select_str($this, $conditions, 'h.');
     print_r($sub_where);
     print_r("<br/>");
     $offset = 1;
     $page_size = 1;
     $sub_where = to_where_str($this, NULL);
     $sub_sql = "select * from tab_sellhouse where " . $sub_where . " order by hid limit {$offset},{$page_size}";
     $select = to_select_str($this, array('*'), 'h.') . ', ' . to_select_str($this, array('true_name', 'contact_mobile'), 'u.');
     $sql = "select {$select} from ({$sub_sql}) h, tab_user u where h.uid = u.uid;";
     print_r($sql);
     print_r("<br/>");
 }