database query

edited June 2014 in Modules
I have written the following function in the locations_model it does what I want it to but am wondering if I should be using the fuel_model here? any tips would be welcomed as I am new to codeigniter and fuel.

function get_europe() {

$europes = fuel_model('locations',array('find' => 'all', 'where' => array('europe' => 'yes', 'published' => 'yes')));
foreach($europes as $europe) {
$data[$europe->id] = $europe->name;
}
return $data;
}

Comments

  • edited 2:28PM
    fuel_model is merely a convenience wrapper function. It's equivalent to the following:
    function get_europe() { $CI =& get_instance(); $europes = $CI->locations_model->find_all(array('europe' => 'yes')); foreach($europes as $europe) { $data[$europe->id] = $europe->name; } return $data; }
    Note that I removed the published => 'yes'. This will be done automatically on the front end.
  • edited 2:28PM
    Thats great thanks for you help and fast response :-)
Sign In or Register to comment.