Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //AssignmentsStudentController.php
- $assistantOptions = array(
- 'joins' => array(
- array(
- 'table' => 'schools_students',
- 'alias' => 'SchoolsStudent',
- 'type' => 'INNER',
- 'conditions' => array('Assistant.id = SchoolsStudent.student_id')
- )
- ),
- 'fields' => array(
- 'Assistant.id',
- 'CONCAT(Assistant.given_name, " ", Assistant.family_name) AS Assistant__assistant_fullname'
- ),
- 'conditions' => array(
- 'Assistant.active' => 1,
- 'Assistant.role_id' => array(4, 5, 6),
- 'SchoolsStudent.assistant' => 1,
- 'SchoolsStudent.school_id' => 1
- ),
- 'order' => array(
- 'Assistant__assistant_fullname' => 'ASC'
- )
- );
- $assistants = $this->AssignmentsStudent->Assistant->find('list', $assistantOptions);
- // Produces the following SQL (This works correctly in SequelPro)
- SELECT `Assistant`.`id`, CONCAT(Assistant.given_name, " ", Assistant.family_name) AS Assistant__assistant_fullname FROM `jwtalks_tms`.`students` AS `Assistant` INNER JOIN `jwtalks_tms`.`schools_students` AS `SchoolsStudent` ON (`Assistant`.`id` = `SchoolsStudent`.`student_id`) WHERE `Assistant`.`active` = '1' AND `Assistant`.`role_id` IN (4, 5, 6) AND `SchoolsStudent`.`assistant` = '1' AND `SchoolsStudent`.`school_id` = 1 ORDER BY `Assistant__assistant_fullname` ASC
- // Array Output is missing Assistant fullname
- Array
- (
- [100] =>
- [41] =>
- [39] =>
- [44] =>
- [67] =>
- [90] =>
- [76] =>
- [49] =>
- [30] =>
- [98] =>
- [102] =>
- [71] =>
- [112] =>
- [57] =>
- [116] =>
- [50] =>
- [17] =>
- [107] =>
- [52] =>
- [92] =>
- [31] =>
- [24] =>
- [18] =>
- [42] =>
- [2] =>
- [56] =>
- [38] =>
- [109] =>
- [83] =>
- [87] =>
- [75] =>
- [68] =>
- [7] =>
- [105] =>
- [85] =>
- [5] =>
- [59] =>
- [69] =>
- [22] =>
- [114] =>
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement