mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
ENHANCEMENT: Added option for putting integers into SS_DATABASE_CHOOSE_NAME in _ss_environment.php, so that a parent/grandparent folder name can be used as the database name (merged from r77261).
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@77264 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
b35dcbed99
commit
6179173d26
@ -15,11 +15,15 @@
|
|||||||
* - SS_DATABASE_PREFIX: A prefix to add to the database name.
|
* - SS_DATABASE_PREFIX: A prefix to add to the database name.
|
||||||
*
|
*
|
||||||
* There is one more setting that is intended to be used by people who work on SilverStripe.
|
* There is one more setting that is intended to be used by people who work on SilverStripe.
|
||||||
* - SS_DATABASE_CHOOSE_NAME: Boolean. If true, then the system will choose a default database name for you if one isn't give
|
* - SS_DATABASE_CHOOSE_NAME: Boolean/Int. If set, then the system will choose a default database name for you if one isn't give
|
||||||
* in the $database variable. The database name will be "SS_" followed by the name of the folder into which you have installed
|
* in the $database variable. The database name will be "SS_" followed by the name of the folder into which you have installed
|
||||||
* SilverStripe. If this is enabled, it means that the phpinstaller will work out of the box without the installer needing to
|
* SilverStripe. If this is enabled, it means that the phpinstaller will work out of the box without the installer needing to
|
||||||
* alter any files. This helps prevent accidental changes to the environment.
|
* alter any files. This helps prevent accidental changes to the environment.
|
||||||
*
|
*
|
||||||
|
* If SS_DATABASE_CHOOSE_NAME is an integer greater than one, then an ancestor folder will be used for the database name. This
|
||||||
|
* is handy for a site that's hosted from /sites/examplesite/www or /buildbot/allmodules-2.3/build. If it's 2, the parent folder
|
||||||
|
* will be chosen; if it's 3 the grandparent, and so on.
|
||||||
|
*
|
||||||
* You can configure the environment with this define:
|
* You can configure the environment with this define:
|
||||||
* - SS_ENVIRONMENT_TYPE: The environment type: dev, test or live.
|
* - SS_ENVIRONMENT_TYPE: The environment type: dev, test or live.
|
||||||
*
|
*
|
||||||
@ -58,7 +62,11 @@ global $database;
|
|||||||
if(!isset($database) || !$database) {
|
if(!isset($database) || !$database) {
|
||||||
// if SS_DATABASE_CHOOSE_NAME
|
// if SS_DATABASE_CHOOSE_NAME
|
||||||
if(defined('SS_DATABASE_CHOOSE_NAME') && SS_DATABASE_CHOOSE_NAME) {
|
if(defined('SS_DATABASE_CHOOSE_NAME') && SS_DATABASE_CHOOSE_NAME) {
|
||||||
$database = "SS_" . basename(dirname(dirname($_SERVER['SCRIPT_FILENAME'])));
|
$loopCount = (int)SS_DATABASE_CHOOSE_NAME;
|
||||||
|
$databaseDir = dirname($_SERVER['SCRIPT_FILENAME']);
|
||||||
|
for($i=0;$i<$loopCount;$i++) $databaseDir = dirname($databaseDir);
|
||||||
|
$database = "SS_" . basename($databaseDir);
|
||||||
|
$database = str_replace('.','',$database);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user