2014-09-21 2 views
-1

codeigniter 모델을 사용하여 배열로 데이터를 삽입하고 다시 검색하십시오.삽입 검색 데이터 배열 codeigniter 모델에서 리트리브 데이터 삽입

모델 :

$data = array( 
       'date'=>$tomorrow_date, 
       'name'=>$name, 
       'phone'=>$phone, 
       'address'=>$address, 
       'age'=>$age, 
       'patient_id'=>id, 



       ); 
    $this->db->insert('user_info',$data); 
} 

가 어떻게 데이터를 삽입 할 수 있습니다 : 나는 같은 삽입 할

function abc { 

    $tomorrow_date=$this->input->post('datee'); 
    $id=$this->input->post('id'); 

    $this -> db -> select('name,phone,address,age'); 
    $this -> db -> from('user_reg'); 
    $this -> db -> where('patient_id',$id); 
    $this -> db -> where('date',$tomorrow_date); 
    $query = $this -> db -> get(); 

    if ($query->num_rows() > 0) 
    { 
    $row = $query->row(); 

    } 

?

답변

0
function abc { 

    $tomorrow_date=$this->input->post('datee'); 
    $id=$this->input->post('id'); 

    $this -> db -> select('name,phone,address,age'); 
    $this -> db -> from('user_reg'); 
    $this -> db -> where('patient_id',$id); 
    $this -> db -> where('date',$tomorrow_date); 
    $query = $this -> db -> get()->row_array(); 

    if ($query->num_rows() > 0){ 

     $data = array( 
      'date'=>$tomorrow_date, 
      'name'=>$query['name'], 
      'phone'=>$query['phone'], 
      'address'=>$query['address'], 
      'age'=>$query['age'], 
      'patient_id'=>$id 
     ); 
    } 

    $this->db->insert('user_info',$data); 
}