Reputation: 614
CodeIgniter
model has following function. Unable to call to another function from inside model. When i tried to call function checkReligion
It says error
Call to undefined function checkReligion()
class maindata_model extends CI_Model {
function get_data_all($gender, $age_min, $age_max, $religion) {
$this->db->select('*');
if($gender == 1) {
$this->db->where('gender', 'F');
$this->db->where('age >=', $age_min);
$this->db->where('age <=', $age_max);
checkReligion($religion) //unable to call from here
}
elseif($gender == 2) {
$this->db->where('gender', 'M');
$this->db->where('age >=', $age_min);
$this->db->where('age <=', $age_max);
checkReligion($religion) //unable to call from here
}
else{
redirect(base_url());
}
$query = $this->db->get('tble_students');
if ($query->num_rows() > 0) {
echo(json_encode($query->result()));
exit();
} else {
return false;
}
}
function checkReligion($religion) {
if ($religion == 1) {
$rTypes = array(2, 3, 4, 5, 6);
$this->db->where_in('religion', $rTypes); //display all religions
} else {
$this->db->where_in('religion', $religion); //display one religion
}
}
}
Upvotes: 0
Views: 46
Reputation: 2587
In your Class to call the method in other method in same class use $this->
before method
$this->checkReligion($religion) ;
Upvotes: 1