Array of String
我在使用 MVC CodeIgniter 時出現錯誤,無法更新我的資料。
我所做的是匯入 excel 檔案并更新系統中的資料。我想更新您可以在模型上看到的資料。首先,我正在嘗試使用靜態資料來檢查它是否有效,請參閱模型。請不要重復,因為每個問題都有不同的解決方法。感謝您抽出寶貴的時間。
模型:
public function updateGrades($updateFields){
$this->db->where('studentID', 200171419);
$this->db->where('updtStatus', 1);
return $this->db->update('tbl_tt_academicinfo', $updateFields);
}
uj5u.com熱心網友回復:
只要$updateFields是多維陣列并且codeigniter更新函式處理一維陣列['key'=>'value'],就必須像這樣在for回圈中使用更新查詢
public function updateGrades($updateFields){
foreach($updateFields as $recoredData){
$this->db->where('studentID', 200171419); // prefer to make it dynamic $recoredData['studentID']
$this->db->where('updtStatus', 1);
$this->db->update('tbl_tt_academicinfo', $recoredData);
}
}
uj5u.com熱心網友回復:
public function updateGrades($updateFields){
$this->db->where('updtStatus', 1);
return $this->db->update_batch('tbl_tt_academicinfo', $updateFields, 'studentID');
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/423098.html
標籤:
上一篇:使用PHPMailer庫發送附件
