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've moved the forum!

Please use for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Showcase Questions /

Feedback and questions about sites in the Community Showcase.

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

Help please..

Go to End

5 Posts   4094 Views


Community Member, 2 Posts

14 July 2011 at 4:48pm

I am confused how to create a database in SilverStripe. I got an assignment to build web database applications. On the web there are laws and regulations. In the Admin there are functions on the user uploaded and there are functions to download and view pdf documents. I'm confused early work in SilverStripe. Please help.


Community Member, 46 Posts

31 July 2011 at 11:36am

You know how to write PHP don't you?
You do know how to set up a new database in phpmyadmin?

That's all you need to know. Silverstripe won't create the database for you. Just add the connection details to _config.php in your project (mysite) folder and you should be done setting up.

After changes to objects, models, extensions or decorators etc, run {url here}/dev/build?flush=all


Forum Moderator, 1899 Posts

31 July 2011 at 9:12pm

What Sphere says is very accurate - but I understand that this is very strange - if you have an assignment I am guessing that create a database means creates a database with tables and data in SQL.

Silverstripe is the first time that I've not had to use SQL to create a basic database structure and manage the data (although within my code there is direct SQL).

Hope this helps!


Community Member, 10 Posts

27 May 2014 at 9:30pm

it's right, you should know PHP to create database in SilverStripe.


Community Member, 8 Posts

6 September 2014 at 2:03am

Edited: 06/09/2014 2:04am

You can create the database before installation of your website, and add the db_name to the site installation, or you can change the database later on by editing the config details (config.php):

i.e. database = mydatabase

$databaseConfig = array(
	"type" => 'MySQLDatabase',
	"server" => 'server domain', //localhost if on own computer
	"username" => 'myusername',
	"password" => 'mypassword',
	"database" => 'mydatabase',
	"path" => ''

Furthermore, Silverstripe has full ORM functionality, so you never have to worry about the database after that. If for example you wanted to add fields to the database, you do it using php code in the silverstripe object.php file.

You want to add a Company Type to a company object


class Company extends DataObject{
    private static $db = array(

Compiling it using url/dev/build will create the extra field in the object on its own.

Here is a full guide: