Added table references to many-many join used by scaffolder, to remove 'ambiguous column' bugs

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@60909 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Sam Minnee 2008-08-18 00:49:44 +00:00
parent ffb5d82bc2
commit 2d0233f2b1

View File

@ -1171,9 +1171,9 @@ class DataObject extends ViewableData implements DataObjectInterface {
list($parentClass, $componentClass, $parentField, $componentField, $table) = $this->many_many($componentName);
if($baseTable == $parentClass) {
return "LEFT JOIN `$table` ON (`$parentField` = `$parentClass`.`ID` AND `$componentField` = '{$this->ID}')";
return "LEFT JOIN `$table` ON (`$table`.`$parentField` = `$parentClass`.`ID` AND `$table`.`$componentField` = '{$this->ID}')";
} else {
return "LEFT JOIN `$table` ON (`$componentField` = `$componentClass`.`ID` AND `$parentField` = '{$this->ID}')";
return "LEFT JOIN `$table` ON (`$table`.`$componentField` = `$componentClass`.`ID` AND `$table`.`$parentField` = '{$this->ID}')";
}
}