Jump to:

3373 Posts in 998 Topics by 712 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Using Dataobject in Sapphire Framework

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

Page: 1
Go to End
Author Topic: 392 Views
  • johannes
    Avatar
    Community Member
    20 Posts

    Using Dataobject in Sapphire Framework Link to this post

    For a new project I tried the standalone Sapphire framework. I got it up and running, but have no idea how to use the Dataobject apart from the CMS.
    All I want to do is saving a simple data set to the database. Therefor I created an Databobject, but when I try to create a new object in the controller, I end up with the error "Class not found".

    Can someone give me a hint, or is the a beginners guide for the framework.

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: Using Dataobject in Sapphire Framework Link to this post

    DataObject is part of the framework. You can create objects using $obj = new NameofYourObject();

    You won't be able to create Page dataobjects (that's part of the CMS)

  • johannes
    Avatar
    Community Member
    20 Posts

    Re: Using Dataobject in Sapphire Framework Link to this post

    Didn't work for me. I tried to initialize a new DataObject in my controller with $my_object = new MyDataObject(); but just end up with the error "Fatal error: Class 'MyDataObjectt' not found..."

    Do I have to build, load the DataObject somewhere?

    The DataObject is pretty basic stuff, just contains some DB fields:

    class MyDataObject extends DataObject {

    static $db = array(
    'ID' => 'Int'
    // other stuff
    );
    }

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: Using Dataobject in Sapphire Framework Link to this post

    Is your new DataObject class being picked up by the manifest? If you run a dev/build you should see it listed (as well as in your database).

  • johannes
    Avatar
    Community Member
    20 Posts

    Re: Using Dataobject in Sapphire Framework Link to this post

    Actually it wasn't, thanks for pointing it out!

    I kind of messed up the routes.yml, so the build didn't work for me >.< To be honest I don't really understand this file so far, it's more like try and error. But I guess it will get easier with the time.

    Sapphire is great fun to work with.

    392 Views
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.