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.

General Questions

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Database Connectivity


Reply

4 Posts   1076 Views

Avatar
Grumble

15 June 2009 at 5:37pm Community Member, 1 Post

Hi. I'm new to CMSs and am choosing one to work with. If you have a good answer to the following question, I'm yours.
Lets say I have a large product database. I want to either:
- load the database into SilverStripe, so I can display it, or
- let SilverStripe read the database, displaying fields on a page, or
- access the source code of a page, so I can insert my own php commands to access the database.
Is any of this possible? If so, how?
Really basic question I would have thought, but I can't find anything about it.

Cheers,
Grumble.

Avatar
Willr

15 June 2009 at 6:12pm Forum Moderator, 5511 Posts

If you want to interact with the Database you can use the ORM layer - eg to get all the products you can do DataObject::get('Product') which will return a set of Product elements. If you want to bypass that (and sometimes its faster) you can use SQLQuery - http://doc.silverstripe.com/doku.php?id=sqlquery

Avatar
wundabred

19 September 2009 at 5:44am Community Member, 1 Post

What if I have all of the info I need in the database, but do not know how to CREATE the database? e.g. I am contemplating Silverstripe for my company's CMS and website, and need to create pricing tables for our products. I would like for these tables to be database driven, for ease of updating. Suggestions?

Many thanks,
-
WB

Avatar
dalesaurus

19 September 2009 at 7:50am Community Member, 283 Posts

@wundabred That is pretty trivial with SS. Once you create your custom DataObject representing your products and build the tables will be created. Next step is to load your data ( pause here... many ways to do this).

The data is easily maintained with the ModelAdmin, which provides full CRUD operations for your tables in a pleasant GUI. It only takes a few lines of code to use it:
http://doc.silverstripe.com/doku.php?id=modeladmin