- $query->write("JOIN", $relation->foreignTable)->write("ON")->criteria(
- array(
- "{$relation->referencedTable}.{$relation->referencedColumn}=" =>
- new QueryExpr("{$relation->foreignTable}.{$relation->foreignColumn}")
- )
- );
+ $query->write("JOIN", $relation->foreignTable)->write("ON");
+ foreach ($relation as $key => $ref) {
+ $query->criteria(
+ array(
+ "{$relation->referencedTable}.{$ref}=" =>
+ new QueryExpr("{$relation->foreignTable}.{$key}")
+ )
+ );
+ }