You need to make sure the array
extension is loaded: http://datamapper.wanwizard.eu/pages/extensions.html
You can either do this globally in the DataMapper config file:
$config['extensions'] = array('array');
Or on the model itself:
class Location extends DataMapper {
var $extensions = array('array');
// ...
}
or dynamically at runtime:
$location = new Location();
$location->load_extension('array');
$results = $location->get()->all_to_array();
That will get rid of the error!
To answer your second question: you shouldn't really need to access the stored
property, and you don't need to return the results as an array either. Use Object-Oriented programming! :)
The best way of achieving what you want to do is to keep the results as objects, then, when looping through them, simply call the property you're after. Then you can keep the code pretty clean:
$locations = new Location();
$locations->get();
foreach( $locations as $location ) {
echo $location->property;
}