我真的很困惑为什么我的 item_id 得到一个 NULL 值,这是我表中的必填字段,也是我首先要搜索的内容,
这是我的控制器的相关部分:
$item_id=$this->uri->segment(4);
$page_data['row'] = $this->item_model->get_item($item_id, TRUE);
var_dump($page_data['row']);
这是我的模型:
function get_item($id, $admin=FALSE){
$this->db
->select('*')
->from('item_entries')
->where('item_entries.item_id', $id)
->join('item_categories_rel', 'item_categories_rel.item_id = item_entries.item_id')
->join('item_descriptions', 'item_descriptions.item_id = item_entries.item_id')
->join('ratings_total', 'ratings_total.item_id = item_entries.item_id')
->join('item_categories', 'item_categories.cat_id = item_categories_rel.cat_id');
if($admin==TRUE){
$this->db
->join('admin_item_alerts', 'admin_item_alerts.item_id = item_entries.item_id')
->join('item_object_code', 'item_object_code.item_id = item_entries.item_id', 'left');
}
$query = $this->db->get();
return $query->row_array();
}
这是 var_dump 的输出:
array(21) { ["item_id"]=> NULL ["item_name"]=> string(9) "MediaInfo" ["item_img"]=> string(13) "mediaInfo.gif" ["item_link"]=> string(42) "http://sourceforge.net/projects/mediainfo/" ["is_code"]=> string(1) "n" ["is_pick"]=> string(1) "n" ["is_quicklink"]=> string(1) "n" ["date_added"]=> string(19) "2010-10-01 00:03:04" ["rel_id"]=> string(3) "132" ["cat_id"]=> string(2) "10" ["item_desc"]=> string(9) "desc_here" ["site_rating"]=> string(3) "3.0" ["urate_ave"]=> string(3) "0.0" ["parent_id"]=> string(1) "2" ["gparent_id"]=> string(1) "0" ["sort_order"]=> string(1) "0" ["cat_name"]=> string(2) "PC" ["cat_slug"]=> string(2) "pc" ["date_checked"]=> string(19) "0000-00-00 00:00:00" ["UpCode"]=> string(1) "N" ["item_code"]=> NULL }
有谁知道它为什么对我这样做:(?