Skip to content
Snippets Groups Projects
Database.php 2.34 KiB
Newer Older
  • Learn to ignore specific revisions
  •      * The directory that holds the Migrations and Seeds directories.
    
        public string $filesPath = APPPATH . 'Database' . DIRECTORY_SEPARATOR;
    
         * Lets you choose which connection group to use if no other is specified.
    
        public string $defaultGroup = 'default';
    
        /**
         * The default database connection.
         *
    
         * @var array<string, string|bool|int|array>
    
            'DSN' => '',
            'hostname' => 'localhost',
            'username' => '',
            'password' => '',
            'database' => '',
            'DBDriver' => 'MySQLi',
    
            'pConnect' => false,
            'DBDebug' => ENVIRONMENT !== 'production',
    
            'charset' => 'utf8mb4',
            'DBCollat' => 'utf8mb4_unicode_ci',
    
            'swapPre' => '',
            'encrypt' => false,
            'compress' => false,
            'strictOn' => false,
            'failover' => [],
            'port' => 3306,
        ];
    
         * This database connection is used when running PHPUnit database tests.
    
         * @noRector StringClassNameToClassConstantRector
         *
    
         * @var array<string, string|bool|int|array>
    
            'DSN' => '',
            'hostname' => '127.0.0.1',
            'username' => '',
            'password' => '',
            'database' => ':memory:',
            'DBDriver' => 'SQLite3',
    
            'pConnect' => false,
            'DBDebug' => ENVIRONMENT !== 'production',
            'charset' => 'utf8',
            'DBCollat' => 'utf8_general_ci',
            'swapPre' => '',
            'encrypt' => false,
            'compress' => false,
            'strictOn' => false,
            'failover' => [],
            'port' => 3306,
        ];
    
        //--------------------------------------------------------------------
    
        public function __construct()
        {
            parent::__construct();
    
            // Ensure that we always set the database group to 'tests' if
            // we are currently running an automated test suite, so that
            // we don't overwrite live data on accident.
            if (ENVIRONMENT === 'testing') {
                $this->defaultGroup = 'tests';
            }
        }
    
        //--------------------------------------------------------------------