Database.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. <?php namespace Config;
  2. /**
  3. * Database Configuration
  4. *
  5. * @package Config
  6. */
  7. class Database extends \CodeIgniter\Database\Config
  8. {
  9. /**
  10. * The directory that holds the Migrations
  11. * and Seeds directories.
  12. *
  13. * @var string
  14. */
  15. public $filesPath = APPPATH . 'Database/';
  16. /**
  17. * Lets you choose which connection group to
  18. * use if no other is specified.
  19. *
  20. * @var string
  21. */
  22. public $defaultGroup = 'default';
  23. //i added next line
  24. /**
  25. * The default database connection.
  26. *
  27. * @var array
  28. */
  29. public $default = [
  30. 'DSN' => '',
  31. 'hostname' => 'localhost',
  32. 'username' => '',
  33. 'password' => '',
  34. 'database' => ROOTPATH.'writable/Art',
  35. 'DBDriver' => 'SQLite3',
  36. 'DBPrefix' => '',
  37. 'pConnect' => false,
  38. 'DBDebug' => (ENVIRONMENT !== 'production'),
  39. 'cacheOn' => false,
  40. 'cacheDir' => '',
  41. 'charset' => 'utf8',
  42. 'DBCollat' => 'utf8_general_ci',
  43. 'swapPre' => '',
  44. 'encrypt' => false,
  45. 'compress' => false,
  46. 'strictOn' => false,
  47. 'failover' => [],
  48. 'port' => 3306,
  49. ];
  50. public $custom = [
  51. 'DSN' => '',
  52. 'hostname' => 'localhost',
  53. 'username' => '',
  54. 'password' => '',
  55. 'database' => ROOTPATH.'writable/Art2',
  56. 'DBDriver' => 'SQLite3',
  57. 'DBPrefix' => '',
  58. 'pConnect' => false,
  59. 'DBDebug' => (ENVIRONMENT !== 'production'),
  60. 'cacheOn' => false,
  61. 'cacheDir' => '',
  62. 'charset' => 'utf8',
  63. 'DBCollat' => 'utf8_general_ci',
  64. 'swapPre' => '',
  65. 'encrypt' => false,
  66. 'compress' => false,
  67. 'strictOn' => false,
  68. 'failover' => [],
  69. 'port' => 3306,
  70. ];
  71. /**
  72. * This database connection is used when
  73. * running PHPUnit database tests.
  74. *
  75. * @var array
  76. */
  77. public $tests = [
  78. 'DSN' => '',
  79. 'hostname' => '127.0.0.1',
  80. 'username' => '',
  81. 'password' => '',
  82. 'database' => ROOTPATH.'writable/Art',
  83. 'DBDriver' => 'SQLite3',
  84. 'DBPrefix' => 'db_', // Needed to ensure we're working correctly with prefixes live. DO NOT REMOVE FOR CI DEVS
  85. 'pConnect' => false,
  86. 'DBDebug' => (ENVIRONMENT !== 'production'),
  87. 'cacheOn' => false,
  88. 'cacheDir' => '',
  89. 'charset' => 'utf8',
  90. 'DBCollat' => 'utf8_general_ci',
  91. 'swapPre' => '',
  92. 'encrypt' => false,
  93. 'compress' => false,
  94. 'strictOn' => false,
  95. 'failover' => [],
  96. 'port' => 3306,
  97. ];
  98. //--------------------------------------------------------------------
  99. public function __construct()
  100. {
  101. parent::__construct();
  102. // Ensure that we always set the database group to 'tests' if
  103. // we are currently running an automated test suite, so that
  104. // we don't overwrite live data on accident.
  105. if (ENVIRONMENT === 'testing')
  106. {
  107. $this->defaultGroup = 'tests';
  108. // Under Travis-CI, we can set an ENV var named 'DB_GROUP'
  109. // so that we can test against multiple databases.
  110. if ($group = getenv('DB'))
  111. {
  112. if (is_file(TESTPATH . 'travis/Database.php'))
  113. {
  114. require TESTPATH . 'travis/Database.php';
  115. if (! empty($dbconfig) && array_key_exists($group, $dbconfig))
  116. {
  117. $this->tests = $dbconfig[$group];
  118. }
  119. }
  120. }
  121. }
  122. }
  123. //--------------------------------------------------------------------
  124. }