saikat chakrabortty saikat chakrabortty - 5 months ago 8
PHP Question

retrive a single data from database in codeigniter

//model

function get(){
$this->db->select('userPic');
$this->db->where('userName', 'back1');
$query = $this->db->get('tbl_users');
return $result = $query->result();

}


//controller

public function index() {
$this->load->model('User_model');
$this->data1['result'] = $this->User_model->get();
// $this->load->view('photo/photo', $this->data1);
echo "$data1";

}

Answer

i think you're using CI2

function get(){

return $this->db->select('userPic')
                  ->get_where('userName', 'back1')
                  ->row();

}