Jump to:

3460 Posts in 1064 Topics by 739 members

Data Model Questions

SilverStripe Forums » Data Model Questions » defining a dataobject for a table not created by silverstripe

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

Page: 1
Go to End
Author Topic: 365 Views
  • MJA
    Community Member
    15 Posts

    defining a dataobject for a table not created by silverstripe Link to this post

    Hello Guys

    This is quite involved, so please bear with me.

    I am trying to read a table created outside of Silverstripe (see attached clip). However, SS is not recognising the data object.

    The site is running off of a MicroSoft database rather than the more usual MySQL database, but this does not seem to be a problem. When I create data objects in SS and run mysite/dev/build the data tables appear in the database exactly as I would expect.

    In order for SS to read the table in obviously needs a definition for it in the data model. To give it this I created a DataModel extension as normal:

       class DocEditorAssets extends DataObject {
          public static $singular_name   = 'Document Editor Asset';
          public static $plural_name      = 'Document Editor Assets';
          public static $db = array (
             'asset_id'         => 'Int',
             'name'            => 'Varchar(255)',
             'version'         => 'Float',
             'updated'         => 'SS_Datetime',
             'text'            => 'Text',
             'updated_by'      => 'Varchar(255)',
             'category'         => 'Varchar(50)',
             'status_id'         => 'Int',
             'rejected_reason'   => 'Varchar(2000)',
             'locked_by'         => 'Varchar(255)'
       }   // end class DocEditorAssets

    and then ran mysite/dev/build

    I had expected SS to pick up the definition, find that the table already existed and proceed as normal, possible appending a couple of fields to the table (ClassName, Created, etc). However, what actually happened was -- nothing at all.

    There was no entry in the dev/build listing which would indicate that SS had picked up the definition and tried to create and/or modify the table (i.e. it did not list DocEditorAssets as I would have expected).

    I cannot understand why this should be. There is, as far as I can see, nothing wrong with the definition and, apart from being created by an external system, there is nothing unusual about the table.

    Any help you can offer will be greatly appreciated.

    Thanks in advance.

    Attached Files
Page: 1
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.