2014-11-15 1 views
0

내 SQL 내에서 문자열을 변경해야합니다, 스크립트는 오류없이 작동하지만 아무것도하지 않습니다. 내가 변경하고자하는 행 ID를 입력하고 그 행 변수를 변경하는 조건을 입력하려고합니다. 여기 내 코드가있다.CodeIgniter 올바르게 내 SQL 테이블을 변경하지 마십시오

컨트롤러 :

public function admin(){ 
$this->load->model('model_users'); 
$data2['users'] = $this->model_users->change_condition(); 
$this->load->view("content_admin", $data2); 
} 

모델 :

public function change_condition() { 
$data = array(
    'order_condition' => $this->input->post('order_condition') 
    ); 
$where = array(
    'ID' => $this->input->post('ID') 
     ); 
$str = $this->db->update_string('users', $data, $where); 
} 

보기 :

<form name="contactform" method="POST" action="<?php echo base_url();?>site/change"> 
<td valign="top"> 
ID 
</td> 
<input type="text" name="ID" maxlength="20" size="30"> 
<td valign="top"> 
Order Condition 
</td> 
<input type="text" name="order_condition" maxlength="80" size="30"> 
<input type="submit" value="Change" name="submit" /> 
</form> 

답변

0

대신 $this->db->update_string$this->db->update()를 사용하고 $this->db->where()$where 배열을 전달해야한다. Example :

+0

코드는 완벽하게 작동하지만 지금은 왜 그런 일이 발생했는지 전혀 모른다는 문제가 있습니다. 그래서, 당신의 코드를 사용하여 db 안에 아이템을 추가했지만, change_condition2()라고 불리는 코드가 2 개 필요합니다. 그래서, 두 코드는 작동, 내 DB에 항목을 추가하지만 지금은 change_condition()을 변경할 때 동일한 행의 change_condition2()가 0과 동일 해집니다. change_condition2()를 변경하면 모든 것이 정상입니다. 왜 이런 일이 일어날 지 모르겠다. 내가 mannualy MSQL을 통해 데이터베이스 내부 항목을 추가하고 모든게 잘 작동하므로 DB의 잘못이 작동합니다. 어쩌면이 문제에 도움을 줄 수 있습니다. –

관련 문제