SproutCMS

This is the code documentation for the SproutCMS project

source of /sprout/config/database.php

Database connection settings.

Each array is a separate group, which can be connected to independently.

The standard connection used by Pdb is the 'default' group, but
the method Pdb::connect can be used to connect to other groups

Group Options:
 connection      Array of connection specific parameters:
      type       Only supported value is 'mysql'
      host       Hostname
      user       Username
      pass       Password
      port       If non-empty, specifies a non-standard port
      database   Database name
 character_set   Database character set
  1. <?php
  2. /**
  3. * Database connection settings.
  4. *
  5. * Each array is a separate group, which can be connected to independently.
  6. *
  7. * The standard connection used by {@see Pdb} is the 'default' group, but
  8. * the method {@see Pdb::connect} can be used to connect to other groups
  9. *
  10. * Group Options:
  11. * connection Array of connection specific parameters:
  12. * type Only supported value is 'mysql'
  13. * host Hostname
  14. * user Username
  15. * pass Password
  16. * port If non-empty, specifies a non-standard port
  17. * database Database name
  18. * character_set Database character set
  19. **/
  20.  
  21.  
  22. if (IN_PRODUCTION) {
  23. // Live server config
  24. $config['default'] = [
  25. 'connection' => [
  26. 'type' => 'mysql',
  27. 'user' => ' -- username -- ',
  28. 'database' => ' -- database -- ',
  29. 'host' => 'localhost',
  30. 'port' => FALSE,
  31. ],
  32. 'prefix' => 'sprout_',
  33. 'character_set' => 'utf8',
  34. 'hacks' => [
  35. 'no_engine_substitution',
  36. ],
  37. ];
  38.  
  39. // Rather than entering the PRODUCTION database password direct in
  40. // the config (which would then be saved in repo history and could
  41. // accidently become public), it's much better to include this in
  42. // a separate file, preferably outside of DOCROOT.
  43. //
  44. // Example file content:
  45. // <?php
  46. // $config['default']['connection']['pass'] = 'abcd1234';
  47. //
  48. // The example path below would be used if the file is a sibling
  49. // of the main public_html directory
  50. //
  51. if (file_exists(DOCROOT . '../database.config.php')) {
  52. require DOCROOT . '../database.config.php';
  53. }
  54.  
  55. // A unique random key for this site
  56. $config['server_key'] = '';
  57.  
  58. } else {
  59. // Test server config
  60. $config['default'] = [
  61. 'connection' => [
  62. 'type' => 'mysql',
  63. 'user' => ' -- username -- ',
  64. 'pass' => ' -- password -- ',
  65. 'database' => ' -- database --',
  66. 'host' => 'localhost',
  67. 'port' => FALSE,
  68. ],
  69. 'prefix' => 'sprout_',
  70. 'character_set' => 'utf8',
  71. 'hacks' => [
  72. 'no_engine_substitution',
  73. ],
  74. ];
  75.  
  76. // This key is not secure, so it must not be used in production environments
  77. $config['server_key'] = 'NOT SECURE';
  78. }
  79.