我有一個名爲表uploaded_files在我的數據庫,在那裏我有以下字段:活動記錄問題返回陣列(笨)
ID,FILE_NAME,upload_id,filetype_id
這最後一個字段(filetype_id)是一個外鍵的表稱爲文件類型在那裏我有這些字段:
ID,filetype_desc
我想在我的模型來創建一個方法返回的所有字段表uploaded_files,陣列中的以下這樣的結構:
array(
'file_type_1' => array(
'id' => 1,
'file_name' => "lalala.txt",
'upload_id' => $uploadId,
'filetype_id' => 1
),
'file_type_2' => array(
'id' => 1,
'file_name' => "lelele.txt",
'upload_id' => $uploadId,
'filetype_id' => 2
),
'file_type_3' => array(
'id' => 1,
'file_name' => "blabla.txt",
'upload_id' => $uploadId,
'filetype_id' => 3
),
);
}
到現在爲止,我來到這個:
public function get_UploadedFilesFromUploadId($uploadId){
//$query = "select * from uploaded_files where upload_id =".$uploadId;
$query = $this->db->get_where('uploaded_files', array(
'upload_id' => $uploadId
)
);
return $this->db->query($query);
}
什麼似乎是問題?你有什麼失敗的嘗試? – DevlshOne