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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

General Questions /

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

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

Displaying data from database table

Go to End

5 Posts   3869 Views


Community Member, 50 Posts

5 August 2009 at 10:45am

I'm feeling somewhat stupid at the moment. I have been through the tutorials and done all 5 of them and have not been able to work out how to dispaly data from a table. I want to simply display data from a table that I have successfully created in the data base. This is a simple table with 3 columns in it. All I want to do is display the data from one or more of these columns on each page of my site. I just want the most basic way of doing this to start off.

Some help on the basic syntax would be much appreciated.


Community Member, 57 Posts

6 August 2009 at 6:30am

In the controller (php):

public function MyThing()
   return DataObject::get("TableName");

In the template:

<% control MyThing %>
<li>This is the Title: $Title</li>
<% end_control %>

I suggest you re-read the tutorials more carefully because they're very good!


Community Member, 50 Posts

6 August 2009 at 11:39am

Thanks for that. It was exactly what I needed. I agree that the tutorials are pretty good. However they are designed with a specific goal in mind ie whatever it is that they have said they are going to create. When you want to do something slightly different and you are not familiar with the fundamentals of how things work it can be extremely time consuming to work out what to do.

Again thanks for your help I am now happy to work out how to do the more complex things which are my actual end goal.


Community Member, 57 Posts

6 August 2009 at 6:34pm

I know what you mean.

By the way, check out, which explains how to use DataObject a bit more.

Have fun SilverStriping!




Community Member, 1 Post

19 August 2009 at 10:30pm


I guess I got stuck with the same as ronin. I tried the suggested solution but there is only one line appearing on my website, instead of showing all the approx 300 lines which are stored in the table.

I made the tutorials 2 and 5 which are related to data handling, but as ronin already said, it is hard for a newbie like me to transfer some things from the tutorials to individual soluitions which may me much simpler but dont work.

can somebody assist please?

thank you very much in advance