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.
We've moved the forum!
Please use forum.silverstripe.org 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.
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
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!
it's right, you should know PHP to create database in SilverStripe.
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
<?php
class Company extends DataObject{
private static $db = array(
"Type"=>"Varchar(100)"
}
}
Compiling it using url/dev/build will create the extra field in the object on its own.
Here is a full guide:
http://doc.silverstripe.com/framework/en/topics/datamodel