我在使用update_batch發佈時收到此錯誤。我已經看到了其他職位,但我的行參考是DB_active_rec.php文件,其他人在他們的MC中看到它。該錯誤不會阻止發佈的update_batch,並且它會爲每個$ rb_items返回錯誤。 Codeigniter數組到字符串轉換錯誤
控制器:
public function update_rb(){
$rb_items = array();
$rb_id=$this->input->post('id', TRUE);
$rb_brand=$this->input->post('brand', TRUE);
$rb_tasted=$this->input->post('tasted', TRUE);
$rb_rating=$this->input->post('rating', TRUE);
$rb_comment=$this->input->post('comment', TRUE);
$i=0;
foreach($rb_id as $id){
$rb_items[$i] = array(
'id'=>$id,
'brand'=>$rb_brand[$i],
'rating'=>$rb_rating[$i],
'comment'=>$rb_comment[$i]
);
if(empty($rb_tasted)){
$rb_items[$i]['tasted']=0;
} else if
(in_array($id,$rb_tasted)){
$rb_items[$i]['tasted']=1;
} else{
$rb_items[$i]['tasted']=0;
}
$i++;
}
$this->model->update_rb($rb_items);
}
型號:
public function update_rb($rb_items){
$this->rb_db->update_batch('rb_selection',$rb_items,'id');
}
查看:
<tr>
<input type="hidden" name="id[]" value="<?php echo $row['id'];?>">
<input type="hidden" name="brand[]" value="<?php echo $row['brand'];?>">
<td><?php echo "<p>".$row['brand']."</p>";?></td>
<td><input type="checkbox" <?php if($row['tasted'] == 1){echo "checked = checked";}?> name="tasted[]" value="<?php echo $row['id'];?>" id="tasted"/></td>
<td><input type="text" name="rating[]" <?php echo $row['rating'];?>/></td>
<td><textarea name='comment[]' id='comment' cols="350"><?php echo $row['comment'];?></textarea></td>
</tr>
有沒有人見過這個錯誤,或者知道我在我的代碼很想念?謝謝您的幫助!
print_r($rb_items)
返回Array ([0] => Array ([rb_id] => 192 [brand] => Napa Valley Soda Co [rating] => r0 [comment] => c0 [tasted] => 1) [1] => Array ([rb_id] => 193 [brand] => Natural Brew [rating] => r1 [comment] => c1 [tasted] => 1) [2] => Array ([rb_id] => 194 [brand] => Naturale 90 [rating] => r2 [comment] => c2 [tasted] => 1))
爲有三個品牌的視圖。無論錯誤如何,所有這些都可以正確發佈。
感謝您的鏈接。 +1 – machineaddict