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.

DataObjectManager Module /

Discuss the DataObjectManager module, and the related ImageGallery module.

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

File database table has no SortOrder field


Go to End


12 Posts   5070 Views

Avatar
wien

Community Member, 2 Posts

16 January 2010 at 8:15pm

Hello.

So I just (a few hours ago) set up a clean install of Silverstripe 2.3.4 with the latest DOM and swfupload from svn. Upon entering "Files & Images" in the CMS I get a database query exception complaining: "[User Error] Couldn't run query: SELECT `File`.*, `File`.ID, if(`File`.ClassName,`File`.ClassName,'File') AS RecordClassName FROM `File` WHERE (`File`.`ID` = 4) ORDER BY SortOrder ASC LIMIT 1 Unknown column 'SortOrder' in 'order clause'"

A look at the database confirms that the File table does indeed lack the SortOrder field and no amount of rebuilding , cache cleans or database resets seem to spawn it. Looking at some older databases I have that were generated in SS 2.3.2 or 2.3.3 (not quite sure), it seems that the File table does have the SortOrder field. As such, upgrading those installations to 2.3.4 works fine as Silverstripe doesn't delete the SortOrder field.

So, is this a change in Silverstripe that has gone unnoticed, a bug in the latest DOM, or am I doing something wrong here?

Avatar
dhensby

Community Member, 253 Posts

17 January 2010 at 1:06am

Have you re-built the database? Also, are you using DataObjectManager? I think you need that too.

Go to: http://[your domain]/dev/build

That should add the SortOrder column for you.

Avatar
wien

Community Member, 2 Posts

17 January 2010 at 5:23am

By "DOM" above, I meant "Data Object Manager", so yes, I'm using the latest version from svn. Sorry for the confusion. And yes, as I said I've tried rebuilding and resetting the database numerous times, but it doesn't add the SortOrder column for some reason. I can always add it by hand (everything works just fine if I do), but I assume this is supposed to happen automatically?

Avatar
phpadam

Community Member, 1 Post

17 January 2010 at 5:31am

I was having the same problem. I'm a relative newbie, but I've installed SS many times and used DOM on all of them. After a new installation and setup, I downloaded and installed DOM. Did a dev/build, and suddenly, I could not go to the Files and Images page...just got a general fail message with no information. So I reinstalled the entire thing from scratch. New database, new clean upload of SS. Then installed ONLY the DOM module. Did a dev/build. Then got the error page quoted ad the end of this post below.

I then went to an old working installation , grabbed the DOM module from that site, and uploaded it to the new site. When I did a dev/build, I SAW the creation of the sort order listed in the green text.

And after installing the swfmodule, I was able to get to the Files and Images page.

My conclusion is that there is something wrong with the currently hosted version of the DOM module...but as a rank newbie...I could be totally wrong.

Error page:
_________________

[User Error] Couldn't run query: SELECT `File`.ID, `File`.ClassName, `File`.Created, `File`.LastEdited, `File`.Name, `File`.Title, `File`.Filename, `File`.Sort, `File`.ParentID, `File`.OwnerID, `File`.ID, if(`File`.ClassName,`File`.ClassName,'File') AS RecordClassName FROM `File` WHERE (`File`.`ParentID` = 0 AND `File`.ID != 0) ORDER BY SortOrder ASC Unknown column 'SortOrder' in 'order clause'
GET /site/admin/assets/

Line 401 in /homepages/18/d310669642/htdocs/site/sapphire/core/model/MySQLDatabase.php
Source

392 }
393
394 function databaseError($msg, $errorLevel = E_USER_ERROR) {
395 // try to extract and format query
396 if(preg_match('/Couldn\'t run query: ([^\|]*)\|\s*(.*)/', $msg, $matches)) {
397 $formatter = new SQLFormatter();
398 $msg = "Couldn't run query: \n" . $formatter->formatPlain($matches[1]) . "\n\n" . $matches[2];
399 }
400
401 user_error($msg, $errorLevel);
402 }
403 }
404
405 /**
406 * A result-set from a MySQL database.
407 * @package sapphire

Avatar
mtz

Community Member, 17 Posts

17 January 2010 at 6:49am

hi have the same Problem. I renamed the Table Field in SortOrder and then it works until the next dev/build...;(

I think there is and "Name-Space-Problem" with the DataObjectManager and 2.3.4

Avatar
UncleCheese

Forum Moderator, 4102 Posts

17 January 2010 at 8:18am

What do you mean by "I renamed the Table Field in SortOrder". What name space problem are you referring to?

Avatar
Patrick Arlt

Community Member, 15 Posts

17 January 2010 at 1:29pm

I am also having this same problem. Fresh install of 2.3.4 and the latest version of DataObjectManager from the modules page. I think this is an error with DataObjectManager as none of my files are listed in the trace, and there is no 'SortOrder' column in the database, which I'm assuming should have been created.

This is a strange error though becuase its not happening on another installation of SS 2.3.4 with the latest DataObjectManager I'm going to see if I can recreate the error.

Meanwhile here is the trace for my error.

Note: yes i have done dev/build several times with no results.

[User Error] Couldn't run query: SELECT `File`.*, `File`.ID, if(`File`.ClassName,`File`.ClassName,'File') AS RecordClassName FROM `File` WHERE (`File`.`ID` = 4) ORDER BY SortOrder ASC LIMIT 1 Unknown column 'SortOrder' in 'order clause'
GET /~danceafrica/admin/assets/

Line 401 in /home8/danceafrica/public_html/sapphire/core/model/MySQLDatabase.php
Source

392 }
393
394 function databaseError($msg, $errorLevel = E_USER_ERROR) {
395 // try to extract and format query
396 if(preg_match('/Couldn\'t run query: ([^\|]*)\|\s*(.*)/', $msg, $matches)) {
397 $formatter = new SQLFormatter();
398 $msg = "Couldn't run query: \n" . $formatter->formatPlain($matches[1]) . "\n\n" . $matches[2];
399 }
400
401 user_error($msg, $errorLevel);
402 }
403 }
404
405 /**
406 * A result-set from a MySQL database.
407 * @package sapphire

Trace

* Couldn't run query: SELECT `File`.*, `File`.ID, if(`File`.ClassName,`File`.ClassName,'File') AS RecordClassName FROM `File` WHERE (`File`.`ID` = 4) ORDER BY SortOrder ASC LIMIT 1 Unknown column 'SortOrder' in 'order clause'
Line 401 of MySQLDatabase.php
* MySQLDatabase->databaseError(Couldn't run query: SELECT `File`.*, `File`.ID, if(`File`.ClassName,`File`.ClassName,'File') AS RecordClassName FROM `File` WHERE (`File`.`ID` = 4) ORDER BY SortOrder ASC LIMIT 1 | Unknown column 'SortOrder' in 'order clause',256)
Line 102 of MySQLDatabase.php
* MySQLDatabase->query(SELECT `File`.*, `File`.ID, if(`File`.ClassName,`File`.ClassName,'File') AS RecordClassName FROM `File` WHERE (`File`.`ID` = 4) ORDER BY SortOrder ASC LIMIT 1,256)
Line 120 of DB.php
* DB::query(SELECT `File`.*, `File`.ID, if(`File`.ClassName,`File`.ClassName,'File') AS RecordClassName FROM `File` WHERE (`File`.`ID` = 4) ORDER BY SortOrder ASC LIMIT 1)
Line 426 of SQLQuery.php
* SQLQuery->execute()
Line 2531 of DataObject.php
* DataObject->instance_get_one(`File`.`ID` = 4,)
Line 2468 of DataObject.php
* DataObject::get_one(File,`File`.`ID` = 4)
Line 2563 of DataObject.php
* DataObject::get_by_id(File,4)
Line 115 of Filesystem.php
* Filesystem::sync()
Line 109 of AssetAdmin.php
* AssetAdmin->index(HTTPRequest)
Line 159 of Controller.php
* Controller->handleAction(HTTPRequest)
Line 129 of RequestHandler.php
* RequestHandler->handleRequest(HTTPRequest)
Line 119 of Controller.php
* Controller->handleRequest(HTTPRequest)
Line 277 of Director.php
* Director::handleRequest(HTTPRequest,Session)
Line 121 of Director.php
* Director::direct(/admin/assets/)
Line 118 of main.php

Avatar
Patrick Arlt

Community Member, 15 Posts

17 January 2010 at 1:53pm

I just intstalled a fresh copy of SS 2.3.4 and the latest version of DataObjectManager on my local MAMP installation and got this same error. Removing DataObjectManager solves the problem or commenting out this line in the config file. (however this disables DataObjectManager in the assest window which is what I wanted.)

DataObjectManager::allow_assets_override(true);

I can add the 'SortOrder' Column to the File table and it works just fine then.

Go to Top