Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Data Model Questions

How to stop Silverstripe SearchContext from throwing Version Table_Live error


Reply

281 Views

Avatar
Lamin Barrow

5 April 2013 at 10:16am (Last edited: 5 April 2013 10:17am), Community Member, 21 Posts

Consider the following Silverstripe page class

class Page extends SiteTree{

static $has_many = array('OtherDataObjects' => 'DataObjectClass');

public function getSearchContext() {

$fields = new FieldSet(

new TextField('Title', 'Tour'),
new DropdownField('OtherDataObjects', 'Other Data Object', array('data', 'value')
);

$filters = array(
'Title' => new PartialMatchFilter('Title'),
'OtherDataObjects' => new PartialMatchFilter('OtherDataObjects.Title')
);
return new SearchContext(
'Page',
$fields,
$filters
);
}

Adding this search form to a front-end form and posting a search form always results in a [User Error] with a SQL error containing something like this at the end.

AND ("DataObjectClass_Live"."DataObjectClass_Live" LIKE 'title') ORDER BY "Sort" LIMIT 25 OFFSET 0 Table 'database DataObjectClass_Live' doesn't exist

I always get this error when search for items based on the has_many or many_many object relations. I get the same error in SIlverstripe versions 2.4.x and the latest 3.0.x versions.

Any help or pointers will be appreciated.