Database.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. namespace Config;
  3. use CodeIgniter\Database\Config;
  4. /**
  5. * Database Configuration
  6. */
  7. class Database extends Config
  8. {
  9. /**
  10. * The directory that holds the Migrations
  11. * and Seeds directories.
  12. */
  13. public string $filesPath = APPPATH . 'Database' . DIRECTORY_SEPARATOR;
  14. /**
  15. * Lets you choose which connection group to
  16. * use if no other is specified.
  17. */
  18. public string $defaultGroup = 'default';
  19. /**
  20. * The default database connection.
  21. */
  22. public array $default = [
  23. 'DSN' => '',
  24. 'hostname' => 'tfb-database',
  25. 'username' => 'benchmarkdbuser',
  26. 'password' => 'benchmarkdbpass',
  27. 'database' => 'hello_world',
  28. 'DBDriver' => 'MySQLi',
  29. 'DBPrefix' => '',
  30. 'pConnect' => true,
  31. 'DBDebug' => false,
  32. 'charset' => 'utf8',
  33. 'DBCollat' => 'utf8_general_ci',
  34. 'swapPre' => '',
  35. 'encrypt' => false,
  36. 'compress' => false,
  37. 'strictOn' => false,
  38. 'failover' => [],
  39. 'port' => 3306,
  40. 'numberNative' => false,
  41. ];
  42. /**
  43. * This database connection is used when
  44. * running PHPUnit database tests.
  45. */
  46. public array $tests = [
  47. 'DSN' => '',
  48. 'hostname' => '127.0.0.1',
  49. 'username' => '',
  50. 'password' => '',
  51. 'database' => ':memory:',
  52. 'DBDriver' => 'SQLite3',
  53. 'DBPrefix' => 'db_', // Needed to ensure we're working correctly with prefixes live. DO NOT REMOVE FOR CI DEVS
  54. 'pConnect' => false,
  55. 'DBDebug' => true,
  56. 'charset' => 'utf8',
  57. 'DBCollat' => 'utf8_general_ci',
  58. 'swapPre' => '',
  59. 'encrypt' => false,
  60. 'compress' => false,
  61. 'strictOn' => false,
  62. 'failover' => [],
  63. 'port' => 3306,
  64. 'foreignKeys' => true,
  65. 'busyTimeout' => 1000,
  66. ];
  67. public function __construct()
  68. {
  69. parent::__construct();
  70. // Ensure that we always set the database group to 'tests' if
  71. // we are currently running an automated test suite, so that
  72. // we don't overwrite live data on accident.
  73. if (ENVIRONMENT === 'testing') {
  74. $this->defaultGroup = 'tests';
  75. }
  76. }
  77. }