3341 Posts in 982 Topics by 703 members
|Go to End|
28 January 2014 at 1:11pm
I'm having troubles understanding how to access the database portion with silverstripe. I've coded sites in java, ASP.NET (C#), Ruby on Rails, etc.. I have experience with object oriented design mostly and i'm a little confused how it works with silverstripe.
So here are some basic questions I'm hoping somebody will answer:
1. How are database objects saved? For example lets say I have ArticleHolder and ArticlePage php files, just like in extended tutorial. Are those 2 considered database objects? How can I call them?
2. How would I perform simple queries on these objects, for example I want to sort all the articles that came back by a date field that I have setup. Or how would I grab a value from a text field I've setup called myAmazingField?
So basically I'm trying to understand how database works and how can I control it. Do I call queries or do I use built in prefix methods to have it do what I need it to do.
29 January 2014 at 1:29am
In most cases you'll never have to deal with the actual database itself - all CRUD functionality is handled by the DataObject model class. Pages are in fact special DataObjects, that have a whole lot of extra functionality added, but the basics remain the same. This model allows for very sophisticated queries. Read all about it here:
Still, if you really need to, you can use other options, like for instance the DBQuery class. This gives you a bit more freedom, but makes you step outside the Model View Controller setup, making integrating the results somewhat more tricky.
30 January 2014 at 4:16pm
Thank you, that helped a lot.
|Go to Top|