Jump to:

3372 Posts in 998 Topics by 712 members

Data Model Questions

SilverStripe Forums » Data Model Questions » Understanding Database with Silverstripe

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

Page: 1
Go to End
Author Topic: 185 Views
  • Bagzli
    Avatar
    Community Member
    15 Posts

    Understanding Database with Silverstripe Link to this post

    Hi guys,

    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.

  • martimiz
    Avatar
    Forum Moderator
    1035 Posts

    Re: Understanding Database with Silverstripe Link to this post

    Hi

    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:

    http://doc.silverstripe.com/framework/en/topics/datamodel

    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.

    Martine

  • Bagzli
    Avatar
    Community Member
    15 Posts

    Re: Understanding Database with Silverstripe Link to this post

    Thank you, that helped a lot.

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