2017-01-16 37 views
0

我嘗試獲取國家的所有城市,但codeigniter生成錯誤的SQL,爲什麼? 這裏是我的模型Codeigniter在哪裏產生錯誤的查詢

private $cities = "cities"; 

public function get_cities_by_country($country_id){ 
    $this->db->select('id, city'); 
    $this->db->where('country_id', $country_id); 
    $this->db->from($this->cities); 
    return $this->db->get()->result_array(); 
} 

我使用log_message爲$ COUNTRY_ID和$這個 - > DB-> last_query()

INFO - 2017-01-16 18:30:25 --> '7' 
INFO - 2017-01-16 18:30:25 --> 'SELECT `id`, `city` 
FROM (`cities`) 
WHERE `country_id` = \'7\' 
AND `status` = 1' 

我認爲這是一個probliem country_id = \「7 \ ' 謝謝!

回答