You will have to get your head around the difference between a CI model and an ORM model.
In case of CI, the Model class is a singleton (there is only one instance) which is accessed via $this->Model, and from a technical point of view behaves just like a library. It contains only reusable logic, no data, which is returned to your controllers for further processing, leading to ‘fat’ controllers.
With an ORM, every instance of data (usually a table row) is a Model object, which encapsulates both the data and the logic as a self-contained entity. All operations on the data, from custom selections, pre- and post processing, to validation, happens inside the model.
The upside of this is that you no longer have ‘fat’ controllers, they are now doing what they should, which is control the flow from request to output, calling the models and loading the views. The upside is also that no matter from which controller you access your data, access is always consistent, as the model will take care of that for you.
Altough Datamapper allows you to keep creating ‘fat’ controllers using code like in the example above (and to be honest, most users use it like that), the idea is that you add custom methods to your Datamapper models that contain the data handling logic.
So in the above example, create a method in your model:
// get an array of id's and fields based on field selection
public function field_to_array($field)
{
$this->where('field', $field)->get();
$result = array();
foreach($this->all as $record)
{
$result[$record->id] = array(
'id' => $record->id,
'field' => $record->field,
);
}
return $result;
}
and then in your controller just use
$record = new Record();
$array = $record->field_to_array('value');