/** * Privately used by _extract_related_model_info_from_query_param to add a join to $model_name * and store it on $passed_in_query_info * @param string $model_name * @param EE_Model_Query_Info_Carrier $passed_in_query_info * @param string $original_query_param used to extract the relation chain between the queried model and $model_name. * Eg, if we are querying Event, and are adding a join to 'Payment' with the original query param key 'Registration.Transaction.Payment.PAY_amount', * we want to extract 'Registration.Transaction.Payment', in case Payment wants to add default query params so that it will know * what models to prepend onto its default query params or in case it wants to rename tables (in case there are multiple joins to the same table) * @return void */ private function _add_join_to_model($model_name, EE_Model_Query_Info_Carrier $passed_in_query_info, $original_query_param) { $relation_obj = $this->related_settings_for($model_name); $model_relation_chain = EE_Model_Parser::extract_model_relation_chain($model_name, $original_query_param); //check if the relation is HABTM, because then we're essentially doing two joins //If so, join first to the JOIN table, and add its data types, and then continue as normal if ($relation_obj instanceof EE_HABTM_Relation) { $join_model_obj = $relation_obj->get_join_model(); //replace the model specified with the join model for this relation chain, whi $relation_chain_to_join_model = EE_Model_Parser::replace_model_name_with_join_model_name_in_model_relation_chain($model_name, $join_model_obj->get_this_model_name(), $model_relation_chain); $new_query_info = new EE_Model_Query_Info_Carrier(array($relation_chain_to_join_model => $join_model_obj->get_this_model_name()), $relation_obj->get_join_to_intermediate_model_statement($relation_chain_to_join_model)); $passed_in_query_info->merge($new_query_info); } //now just join to the other table pointed to by the relation object, and add its data types $new_query_info = new EE_Model_Query_Info_Carrier(array($model_relation_chain => $model_name), $relation_obj->get_join_statement($model_relation_chain)); $passed_in_query_info->merge($new_query_info); }