This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Put these two functions in your Controller.php | |
//and use like this: | |
//$department = Department::model->findBySql("SELECT * FROM department WHERE department_id=" . $department_id); | |
//$department_data = $this->get_model_associations($department,array('school'=>array('admins','pictureFile')),'students'=>array('pictureFile')); | |
//The first parameter is the model object, and the 2nd is an array of arrays of arrays and deep as you want to go. | |
//walk model detects if the current level is an associative array or just a regular array. If it is associative, | |
//it recursively gets the next layer of relations and then properly nests the data | |