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.

Data Model Questions

Using Dataobject in Sapphire Framework


Reply

5 Posts   484 Views

Avatar
johannes

20 October 2012 at 1:27am Community Member, 20 Posts

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

24 October 2012 at 8:26pm Forum Moderator, 5511 Posts

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

24 October 2012 at 11:06pm Community Member, 20 Posts

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

25 October 2012 at 9:08pm Forum Moderator, 5511 Posts

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

25 October 2012 at 10:00pm Community Member, 20 Posts

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.