for listing values from db using codeigniter rest for web service -
to list values db have been using followin code
model
function user_list_community($servicename) { $ipjson = json_encode($input); $this->db->select('*'); $this->db->from('community'); //$this->db->where('user_id', $input['user_id']); $query = $this->db->get(); $result = $query->result(); if (!empty($result)) { $data['list_community']= $result; $data['message'] = 'user details retrieved successfully.'; $status = $this->ville_lib->return_status('success', $servicename, $data, $ipjson); } else { $data['message'] = 'unable retrieve.please user id'; $status = $this->ville_lib->return_status('error', $servicename, $data, $ipjson); } return $status; }
controller
function list_community_post(){ $servicename = 'list_community'; $retvals = $this->user_model->user_list_community($input, $servicename); header("content-type: application/json"); echo $retvals; exit; }
the issue facing getting values getting error follows. wrong doing here. can me . thanks.
php error encounteredseverity: notice
message: undefined variable: input
filename: controllers/users.php
line number: 57
php error encounteredseverity: notice
message: undefined variable: input
filename: models/user_model.php
line number: 67
you getting error because $input not defined in code. should either this:
function list_community_post(){ $input=''; $servicename = 'list_community'; $retvals = $this->user_model->user_list_community($input, $servicename); header("content-type: application/json"); echo $retvals; exit; }
or
function list_community_post(){ $servicename = 'list_community'; $retvals = $this->user_model->user_list_community($servicename); header("content-type: application/json"); echo $retvals; exit; }
Comments
Post a Comment