当前位置: 动力学知识库 > 问答 > 编程问答 >

php - 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..

网友答案:

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.

网友答案:

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);
分享给朋友:
您可能感兴趣的文章:
随机阅读: