protected function makeResrictionForAsscotion(array &$arrDataRow, $sFromTableName = null, array $arrFromKeys, $sToTableName = null, array $arrToKeys) { $aRestriction = new Restriction(); foreach ($arrFromKeys as $nIdx => $sFromKey) { if ($sFromTableName) { $sFromKey = $sFromTableName . '.' . $sFromKey; } $aRestriction->expression(array(SQL::createRawColumn($sToTableName, $arrToKeys[$nIdx]), '=', SQL::transValue($arrDataRow[$sFromKey])), true, true); } return $aRestriction; }
public static function buildRestriction(Prototype $aPrototype, $values = null, $keys = null) { if ($values === null) { return null; } $keys = $keys ? (array) $keys : $aPrototype->keys(); if ($values instanceof Restriction) { return $values; } else { $aRestriction = new Restriction(); $sSqlTableAlias = $aPrototype->sqlTableAlias(); $values = array_values((array) $values); foreach ($keys as $nIdx => $sKey) { list($sTable, $sColumn) = SQL::splitColumn($sKey); $aRestriction->expression(array(SQL::createRawColumn($sTable, $sColumn), '=', SQL::transValue($values[$nIdx])), true, true); } return $aRestriction; } }