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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Error: Unknown column


Go to End


2 Posts   1247 Views

Avatar
suntrop

Community Member, 141 Posts

29 April 2015 at 9:08am

Edited: 29/04/2015 9:10am

I just updated a website from 2.4 to 3.1.2 and installed translateable-module. Most parts are working now, but I get an error on my news/blog page:

Couldn't run query: SELECT DISTINCT count(DISTINCT "SiteTree"."ID") AS "0" FROM "SiteTree" WHERE (ParentID = 9 AND Datum <= '2015-04-28') AND ("SiteTree"."ClassName" IN ('Page','ArticleHolder','ArticlePage','CategoryHolder','HomePage','ProductHolder','SiteMap','ErrorPage','RedirectorPage','VirtualPage')) AND ("SiteTree"."Locale" = 'de_DE') Unknown column 'Datum' in 'where clause' 

My filter function:

function FilteredChildren($filter = 'Datum DESC') {
	return DataObject::get('Page', "ParentID = {$this->ID} AND Datum <= '" . date('Y-m-d') . "'", $filter);
}

I don't know why it says 'Datum' is missing or unknown. My article's page has this column:

private static $db = array(
        'Datum' => 'Date'
    );
function getCMSFields() {
		$fields = parent::getCMSFields();
		$fields->addFieldToTab('Root.Main', $dateField = new DateField('Datum', 'Artikel Datum'), 'Content');
		$dateField->setConfig('showcalendar', true);
		$dateField->setConfig('dateformat', 'dd.MM.YYYY');
		return $fields;
    }

Avatar
Pyromanik

Community Member, 419 Posts

5 May 2015 at 10:20pm

DataObject::get is not used like that anymore.
DataObject::get('Page', ... - you're looking for a Page, not an article. So nope, that field does not exist (refer to the query - it's only looking at the SiteTree table).

What you should have is DataObject::get('Article', ...

But what you REALLY should have is:

public function FilteredChildren($sort = 'Datum DESC'){return ArticlePage::get()->filter([
	'ParentID' => $this->ID,
	'Datum' => date('Y-m-d')
])->sort($sort);}