/** * Internally called method to assist with early binding of objects * on load methods. Can only early-bind references that this class owns in the database. * @param string $strParentAlias the alias of the parent (if any) * @param string $strAlias the alias of this object * @param array $objExpansionMap map of referenced columns to be immediately expanded via early-binding * @param QueryExpansion an already instantiated QueryExpansion object (used as a utility object to assist with object expansion) */ public static function ExpandQuery($strParentAlias, $strAlias, $objExpansionMap, QQueryExpansion $objQueryExpansion) { if ($strAlias) { $objQueryExpansion->AddFromItem(sprintf('LEFT JOIN `class_property` AS `%s__%s` ON `%s`.`%s` = `%s__%s`.`id`', $strParentAlias, $strAlias, $strParentAlias, $strAlias, $strParentAlias, $strAlias)); $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`id` AS `%s__%s__id`', $strParentAlias, $strAlias, $strParentAlias, $strAlias)); $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`qcodo_class_id` AS `%s__%s__qcodo_class_id`', $strParentAlias, $strAlias, $strParentAlias, $strAlias)); $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`variable_group_id` AS `%s__%s__variable_group_id`', $strParentAlias, $strAlias, $strParentAlias, $strAlias)); $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`variable_id` AS `%s__%s__variable_id`', $strParentAlias, $strAlias, $strParentAlias, $strAlias)); $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`class_variable_id` AS `%s__%s__class_variable_id`', $strParentAlias, $strAlias, $strParentAlias, $strAlias)); $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`read_only_flag` AS `%s__%s__read_only_flag`', $strParentAlias, $strAlias, $strParentAlias, $strAlias)); $objQueryExpansion->AddSelectItem(sprintf('`%s__%s`.`write_only_flag` AS `%s__%s__write_only_flag`', $strParentAlias, $strAlias, $strParentAlias, $strAlias)); $strParentAlias = $strParentAlias . '__' . $strAlias; } if (is_array($objExpansionMap)) { foreach ($objExpansionMap as $strKey => $objValue) { switch ($strKey) { case 'qcodo_class_id': try { QcodoClass::ExpandQuery($strParentAlias, $strKey, $objValue, $objQueryExpansion); break; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'variable_group_id': try { VariableGroup::ExpandQuery($strParentAlias, $strKey, $objValue, $objQueryExpansion); break; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'variable_id': try { Variable::ExpandQuery($strParentAlias, $strKey, $objValue, $objQueryExpansion); break; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } case 'class_variable_id': try { ClassVariable::ExpandQuery($strParentAlias, $strKey, $objValue, $objQueryExpansion); break; } catch (QCallerException $objExc) { $objExc->IncrementOffset(); throw $objExc; } default: throw new QCallerException(sprintf('Unknown Object to Expand in %s: %s', $strParentAlias, $strKey)); } } } }