我對Codeigniter頗爲陌生。我有一個問題,看起來我的查詢不起作用。是因爲我的格式嗎?CodeIgniter用於從不同表中獲取數據的SQL正確格式
型號
$this->db->select('*');
$this->db->from('
store_products,
products,
category,
subcategory,
store,
store_products_category');
$this->db->where('store_products_category.store_id', $marketid);
$this->db->where('store_products_category.subcategory_id', 'subcategory.subcategory_id');
$this->db->where('subcategory.category_id', 'category.category_id');
$this->db->where('store_products_category.storeprod_id', 'store_products.storeprod_id');
$this->db->where('store_products.prod_id', 'products.prod_id');
$this->db->where('store_products_category.store_id', 'store.store_id');
$query = $this->db->get();
$result = $query->row();
return $result;
控制器
if($marketinfo = $this->MarketModel->getInfobyID($marketid)){
$data['marketinfolist'] = $marketinfo;
$this->load->view('layouts/header', $data);
$this->load->view('clickbasket',$data);
$this->load->view('navigation/mainfooter');
$this->load->view('layouts/footer');
}
看來,它不能從模型返回任何東西。我已經嘗試直接在phpmyadmin上執行查詢,並且它完美地工作。
謝謝它現在工作正常:)只是不得不調整$ query-> row()部分 –