|
| 1 | +<?php namespace App\Config\Database; |
| 2 | + |
| 3 | +/** |
| 4 | + * The default connection configuration for the application. |
| 5 | + * |
| 6 | + * This file will contain the settings needed to access your database. |
| 7 | + * |
| 8 | + * Mapping values from CI3 database configuration: |
| 9 | + * $active_group - not set here, see $activeConnection in the application's Database config |
| 10 | + * $query_builder - currently not supported |
| 11 | + * $db - set by a combination of $availableConnections in the application's |
| 12 | + * Database config and files like this one to set the configuration |
| 13 | + * of the individual connections. |
| 14 | + * |
| 15 | + * The following are the keys used in configuring connection groups in CI3's $db |
| 16 | + * property and their equivalent properties in CI4's Database Connection config: |
| 17 | + * 'dsn' - $dsn |
| 18 | + * 'hostname' - $hostname |
| 19 | + * 'username' - $username |
| 20 | + * 'password' - $password |
| 21 | + * 'dbdriver' - Instead of setting this value directly, extend the platform-specific |
| 22 | + * Connection Configuration class (to be added here when available): |
| 23 | + * 'mysqli' - \CodeIgniter\Config\Database\Connection\MySQLi |
| 24 | + * 'dbprefix' - currently not supported |
| 25 | + * 'pconnect' - $persistentConnectionEnabled |
| 26 | + * 'db_debug' - $debugEnabled |
| 27 | + * 'cache_on' - $cacheEnabled - may be modified to reference the cache configuration |
| 28 | + * 'cachedir' - currently not supported (to be configured elsewhere) |
| 29 | + * 'char_set' - $characterSet |
| 30 | + * 'dbcollat' - $collation (MySQLi-only) |
| 31 | + * 'swap_pre' - currently not supported |
| 32 | + * 'encrypt' - (MySQLi-only) instead of an array with the following options, set |
| 33 | + * the associated properties directly: |
| 34 | + * 'ssl_key' - $sslKey |
| 35 | + * 'ssl_cert' - $sslCert |
| 36 | + * 'ssl_ca' - $sslCA |
| 37 | + * 'ssl_capath' - $sslCAPath |
| 38 | + * 'ssl_cipher' - $sslCipher |
| 39 | + * 'ssl_verify' - $sslVerify |
| 40 | + * 'compress' - $compressionEnabled (MySQLi-only) |
| 41 | + * 'stricton' - $strictSQLEnabled |
| 42 | + * 'failover' - $failover Instead of an array containing connection configurations, |
| 43 | + * this will contain values matching keys used in the application's |
| 44 | + * database configuration's $availableConnections property |
| 45 | + * 'save_queries' - $saveStatementsEnabled |
| 46 | + * 'port' - $port |
| 47 | + * |
| 48 | + * Additional configuration options: |
| 49 | + * $deleteHack - (MySQLi-only) |
| 50 | + * |
| 51 | + * The order of the properties below has been arranged (and their values have been |
| 52 | + * set) to match the default connection group in CI3's database config. |
| 53 | + */ |
| 54 | +class DefaultConnection extends \CodeIgniter\Config\Database\Connection\MySQLi |
| 55 | +{ |
| 56 | + /** |
| 57 | + * Data Source Name. |
| 58 | + * |
| 59 | + * A string which will usually contain all of the settings required to connect |
| 60 | + * to a database. Commonly used for database adapters which support multiple |
| 61 | + * database types, like PDO or ODBC. |
| 62 | + * |
| 63 | + * @var string |
| 64 | + */ |
| 65 | + public $dsn = ''; |
| 66 | + |
| 67 | + /** @var string The database server's hostname. */ |
| 68 | + public $hostname = 'localhost'; |
| 69 | + |
| 70 | + /** @var string The username for the database connection. */ |
| 71 | + public $username = ''; |
| 72 | + |
| 73 | + /** @var string The password for the database connection. */ |
| 74 | + public $password = ''; |
| 75 | + |
| 76 | + /** @var string The name of the database. */ |
| 77 | + public $database = ''; |
| 78 | + |
| 79 | + /** @var bool Use a persistent connection. */ |
| 80 | + public $persistentConnectionEnabled = false; |
| 81 | + |
| 82 | + /** @var bool Enable debug messages. */ |
| 83 | + public $debugEnabled = (ENVIRONMENT !== 'production'); |
| 84 | + |
| 85 | + /** @var bool Enable database result caching. */ |
| 86 | + public $cacheEnabled = false; |
| 87 | + |
| 88 | + /** @var string The character set. */ |
| 89 | + public $characterSet = 'utf8'; |
| 90 | + |
| 91 | + /** @var string The character collation used in communicating with the database. */ |
| 92 | + public $collation = 'utf8_general_ci'; |
| 93 | + |
| 94 | + /** @var bool Whether client compression is enabled. */ |
| 95 | + public $compressionEnabled = false; |
| 96 | + |
| 97 | + /** @var bool Forces "Strict Mode" connections to enforce strict SQL. */ |
| 98 | + public $strictSQLEnabled = false; |
| 99 | + |
| 100 | + /** |
| 101 | + * List of connections to use if this one fails to connect. |
| 102 | + * |
| 103 | + * The values in this array should match the keys used in the application's |
| 104 | + * Database config to reference other connection configuration classes. |
| 105 | + * |
| 106 | + * @var array |
| 107 | + */ |
| 108 | + public $failover = []; |
| 109 | + |
| 110 | + /** |
| 111 | + * Whether to "save" all executed SQL statements. |
| 112 | + * |
| 113 | + * Disabling this will also effectively disable application-level profiling |
| 114 | + * of SQL statements. |
| 115 | + * |
| 116 | + * Enabling this setting may cause high memory use, especially when running |
| 117 | + * a lot of SQL statements. |
| 118 | + * |
| 119 | + * @var bool |
| 120 | + */ |
| 121 | + public $saveStatementsEnabled = true; |
| 122 | +} |
0 commit comments