2013-05-16 3 views
0

CodeIgniter를 처음 사용했습니다. 업데이트 용 웹 서비스 REST를 만들고 싶습니다. CodeIgniter 및 REST로 데이터를 업데이트하는 방법

내 컨트롤러 :

function user_post() 
{ 
    $result = $this->user_model->update($this->get('id'), 
     'name' => $this->post('name')); 

    if($result === FALSE) 
    { 
     $this->response(array('status' => 'failed')); 
    } 

    else 
    { 
     $this->response(array('status' => 'success')); 
    } 

} 

그리고이 기능은 내 모델에 있습니다

function update($id, $name) 
{ 
    $sql = "UPDATE user SET name=? WHERE id=?"; 
    $this->db->query($sql, array($name,$id)); 
} 

나는 그것이 작동하지 않습니다 index.php/exemple/user/id/1?method=post/name=Bill하여 함수를 호출

. 아무쪼록 바랍니다.

+0

에서는 작동하지 않습니다? 출력은 무엇입니까? 그리고 나는 당신이 읽어야한다고 생각한다; [CI URLS] (http://ellislab.com/codeigniter/user-guide/general/urls.html) – rcpayan

답변

1

현재 컨트롤러에있는 $result에는 값이 할당되지 않습니다. 당신은 당신의 모델의 update 함수에 return 문을 추가해야합니다

function update($id, $name) 
{ 
    $sql = "UPDATE user SET name=? WHERE id=?"; 
    return $this->db->query($sql, array($name,$id)); 
} 
관련 문제