Jump to:

7938 Posts in 1540 Topics by 945 members

DataObjectManager Module

SilverStripe Forums » DataObjectManager Module » File database table has no SortOrder field

Discuss the DataObjectManager module, and the related ImageGallery module.

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

Page: 1 2
Go to End
Author Topic: 2856 Views
  • wien
    Avatar
    Community Member
    2 Posts

    File database table has no SortOrder field Link to this post

    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?

  • Pigeon
    Avatar
    Community Member
    243 Posts

    Re: File database table has no SortOrder field Link to this post

    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.

  • wien
    Avatar
    Community Member
    2 Posts

    Re: File database table has no SortOrder field Link to this post

    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?

  • phpadam
    Avatar
    Community Member
    1 Post

    Re: File database table has no SortOrder field Link to this post

    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

  • mtz
    Avatar
    Community Member
    17 Posts

    Re: File database table has no SortOrder field Link to this post

    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

  • UncleCheese
    Avatar
    4085 Posts

    Re: File database table has no SortOrder field Link to this post

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

  • Patrick Arlt
    Avatar
    Community Member
    15 Posts

    Re: File database table has no SortOrder field Link to this post

    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

  • Patrick Arlt
    Avatar
    Community Member
    15 Posts

    Re: File database table has no SortOrder field Link to this post

    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.

    2856 Views
Page: 1 2
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.