im using codeigntier framework im trying to solve a problem to do with retrieving information from a database for example:
model.php:
public function read(){
$query = $this->db->get('table');
return $query->result();
}
controller.php:
public function doSomething () {
$exampleArray['name'] = "Bob's Database";
$getModel = $this->load->model('model','getData');
$modelData = $this->getData->read();
// i want to assign the the $modelData to a array element like so
$exampleArray['modelData'] = $modelData // here's where im stuck :(
}
thanks for your help!!
p.s. this is not an error, its just a question 🙂
}
If you want to be able to access
$exampleArrayoutside of that method, you’ll have to do one of two things:a) set it as a class variable
then refer to it using
or b) pass it by reference into your
doSomething()function:The php manual has a section on variable scope that should help you better understand this.