CodeIgniter Forums
Datamapper include_related not extending result set columns - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: Datamapper include_related not extending result set columns (/thread-55985.html)



Datamapper include_related not extending result set columns - El Forum - 11-20-2012

[eluser]Unknown[/eluser]
am using Datamapper and want to join all columns of a related table (1:1 relationship) in the result set. Hence, my code reads as follows:

Code:
$p = new Project();
$arrAll = $p->where("id <", 100)->where_related('outboundform', 'reference_type', 'project')->include_related('outboundform')->get()->all_to_array();
print_r($arrAll);


The query works, but no column of table 'outboundform' shows up in the result, they get completely ignored!! I just checked and the generated SQL reads:

Code:
SELECT `project` . * , `outboundform`.`id` AS outboundform_id, `outboundform`.`reference_type` AS outboundform_reference_type, `outboundform`.`reference_id` AS outboundform_reference_id, `outboundform`.`created` AS outboundform_created, `outboundform`.`updated` AS outboundform_updated, `outboundform`.`v1` AS outboundform_v1, `outboundform`.`v2` AS outboundform_v2, `outboundform`.`v3` AS outboundform_v3, `outboundform`.`v4` AS outboundform_v4, `outboundform`.`v5` AS outboundform_v5 FROM (`project`) LEFT OUTER JOIN `outboundform` outboundform ON `project`.`id` = `outboundform`.`reference_id` WHERE `project`.`id` <100 AND `outboundform`.`reference_type` = 'project' LIMIT 0 , 30


which is OK and gives me the correct result when executed. What's Datamappers problem here? Why is it not return the full amount of columns?