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.

Data Model Questions /

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

Using Dataobject in Sapphire Framework


Go to End


5 Posts   1271 Views

Avatar
johannes

Community Member, 20 Posts

20 October 2012 at 1:27am

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.

Avatar
Willr

Forum Moderator, 5523 Posts

24 October 2012 at 8:26pm

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)

Avatar
johannes

Community Member, 20 Posts

24 October 2012 at 11:06pm

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
);
}

Avatar
Willr

Forum Moderator, 5523 Posts

25 October 2012 at 9:08pm

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).

Avatar
johannes

Community Member, 20 Posts

25 October 2012 at 10:00pm

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.