Hey guys,
So, I've modified an existing SilverStripe site and I'm now suffering a confusing error. Originally, the site would list projects that belonged to the members of the site. These projects were in a one to many relationship, so clients could have multiple projects. However, it now transpires that these projects may have multiple members. Ergo, I had to change the has_one relationship for project members to a has_many relationship. The member object was already being extended using a decorator which looks like this :-
class MemberDecorator extends DataObjectDecorator
{
function extraStatics() {
return array(
'db' => array(
'CompanyName' => 'Varchar'
),
'has_many' => array(
'Projects' => 'Project'
)
);
}
public function updateCMSFields(FieldSet $fields) {
$fields->addFieldToTab('Root.Members', new CheckboxField('RedirectToProjects', 'Redirect to Projects on Login'));
}
}
As you can see, the decorator adds the reciprocal has_many relationship for Projects.
Now, when I try to run the application, I get the error "[User Error] Couldn't run query: SELECT ... FROM "Project" WHERE ("ParentID" = '5') Unknown column 'ParentID' in 'where clause'".
What am I doing wrong? All other posts I've seen with this error are due to a missing "has_one" in the child object. I've not seen a many to many example, though both objects have a relationship notifier in the static "has_many" array. Should I be doing something else to enforce this?
Thanks,
Lee