Bora
Bora

Reputation: 10717

codeIgniter Datamapper Get Only Query Results

I want to save results to cache but datamapper result objects is huge array.

I want to get only my query results without other data that referenced codeigniter data (models/configs/languages/etc..)

How can do this?

I searched on SO, internet and manual page (http://datamapper.wanwizard.eu/) but i couldnt find anything..

Upvotes: 0

Views: 417

Answers (2)

Bora
Bora

Reputation: 10717

I want to addition some tips on @sevenpointsix answer

If you are using include_related, you have to specify columns like following (relation_column):

$fields = array('id', 'title', 'user_firstname', 'user_lastname', 'category_name');
$posts->get()->all_to_array($fields);

Upvotes: 0

sevenpointsix
sevenpointsix

Reputation: 394

If you just want to access the core information about your records, try using the array extension here: http://datamapper.wanwizard.eu/pages/extensions/array.html

This allows you to run something like:

$objects-> all_to_array();

... which returns an array of objects, with all properties, but without the models/configs/languages &c. that you mention.

Upvotes: 1

Related Questions