Skip to content

Commit faaadd6

Browse files
committed
docs: update sample files
1 parent 5eeb988 commit faaadd6

8 files changed

Lines changed: 118 additions & 49 deletions

File tree

user_guide_src/source/database/configuration.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,16 @@ DSN in Universal Manner
5151
You can also set a Data Source Name in universal manner (URL like). In that case DSNs must have this prototype:
5252

5353
.. literalinclude:: configuration/003.php
54+
:lines: 11-14
5455

5556
To override default config values when connecting with a universal version of the DSN string,
5657
add the config variables as a query string:
5758

5859
.. literalinclude:: configuration/004.php
60+
:lines: 11-15
61+
62+
.. literalinclude:: configuration/010.php
63+
:lines: 11-15
5964

6065
.. note:: If you provide a DSN string and it is missing some valid settings (e.g., the
6166
database character set), which are present in the rest of the configuration

user_guide_src/source/database/configuration/001.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,17 @@
66

77
class Database extends Config
88
{
9-
public $default = [
9+
// ...
10+
11+
public array $default = [
1012
'DSN' => '',
1113
'hostname' => 'localhost',
1214
'username' => 'root',
1315
'password' => '',
1416
'database' => 'database_name',
1517
'DBDriver' => 'MySQLi',
1618
'DBPrefix' => '',
17-
'pConnect' => true,
19+
'pConnect' => false,
1820
'DBDebug' => true,
1921
'charset' => 'utf8',
2022
'DBCollat' => 'utf8_general_ci',
Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
<?php
22

3-
$default = [
4-
'DSN' => 'DBDriver://username:password@hostname:port/database',
3+
namespace Config;
4+
5+
use CodeIgniter\Database\Config;
6+
7+
class Database extends Config
8+
{
9+
// ...
10+
11+
public array $default = [
12+
'DSN' => 'DBDriver://username:password@hostname:port/database',
13+
// ...
14+
];
15+
516
// ...
6-
];
17+
}
Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
<?php
22

3-
// MySQLi
4-
$default = [
5-
'DSN' => 'MySQLi://username:password@hostname:3306/database?charset=utf8&DBCollat=utf8_general_ci',
3+
namespace Config;
4+
5+
use CodeIgniter\Database\Config;
6+
7+
class Database extends Config
8+
{
69
// ...
7-
];
810

9-
// Postgre
10-
$default = [
11-
'DSN' => 'Postgre://username:password@hostname:5432/database?charset=utf8&connect_timeout=5&sslmode=1',
11+
// MySQLi
12+
public array $default = [
13+
'DSN' => 'MySQLi://username:password@hostname:3306/database?charset=utf8&DBCollat=utf8_general_ci',
14+
// ...
15+
];
16+
1217
// ...
13-
];
18+
}
Lines changed: 49 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,51 @@
11
<?php
22

3-
$default['failover'] = [
4-
[
5-
'hostname' => 'localhost1',
6-
'username' => '',
7-
'password' => '',
8-
'database' => '',
9-
'DBDriver' => 'MySQLi',
10-
'DBPrefix' => '',
11-
'pConnect' => true,
12-
'DBDebug' => true,
13-
'charset' => 'utf8',
14-
'DBCollat' => 'utf8_general_ci',
15-
'swapPre' => '',
16-
'encrypt' => false,
17-
'compress' => false,
18-
'strictOn' => false,
19-
],
20-
[
21-
'hostname' => 'localhost2',
22-
'username' => '',
23-
'password' => '',
24-
'database' => '',
25-
'DBDriver' => 'MySQLi',
26-
'DBPrefix' => '',
27-
'pConnect' => true,
28-
'DBDebug' => true,
29-
'charset' => 'utf8',
30-
'DBCollat' => 'utf8_general_ci',
31-
'swapPre' => '',
32-
'encrypt' => false,
33-
'compress' => false,
34-
'strictOn' => false,
35-
],
36-
];
3+
namespace Config;
4+
5+
use CodeIgniter\Database\Config;
6+
7+
class Database extends Config
8+
{
9+
// ...
10+
11+
public array $default = [
12+
// ...
13+
'failover' => [
14+
[
15+
'hostname' => 'localhost1',
16+
'username' => '',
17+
'password' => '',
18+
'database' => '',
19+
'DBDriver' => 'MySQLi',
20+
'DBPrefix' => '',
21+
'pConnect' => true,
22+
'DBDebug' => true,
23+
'charset' => 'utf8',
24+
'DBCollat' => 'utf8_general_ci',
25+
'swapPre' => '',
26+
'encrypt' => false,
27+
'compress' => false,
28+
'strictOn' => false,
29+
],
30+
[
31+
'hostname' => 'localhost2',
32+
'username' => '',
33+
'password' => '',
34+
'database' => '',
35+
'DBDriver' => 'MySQLi',
36+
'DBPrefix' => '',
37+
'pConnect' => true,
38+
'DBDebug' => true,
39+
'charset' => 'utf8',
40+
'DBCollat' => 'utf8_general_ci',
41+
'swapPre' => '',
42+
'encrypt' => false,
43+
'compress' => false,
44+
'strictOn' => false,
45+
],
46+
],
47+
// ...
48+
];
49+
50+
// ...
51+
}

user_guide_src/source/database/configuration/006.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66

77
class Database extends Config
88
{
9-
public $test = [
9+
// ...
10+
11+
public array $test = [
1012
'DSN' => '',
1113
'hostname' => 'localhost',
1214
'username' => 'root',
Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
11
<?php
22

3-
$defaultGroup = 'test';
3+
namespace Config;
4+
5+
use CodeIgniter\Database\Config;
6+
7+
class Database extends Config
8+
{
9+
// ...
10+
11+
public string $defaultGroup = 'test';
12+
13+
// ...
14+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace Config;
4+
5+
use CodeIgniter\Database\Config;
6+
7+
class Database extends Config
8+
{
9+
// ...
10+
11+
// Postgre
12+
public array $default = [
13+
'DSN' => 'Postgre://username:password@hostname:5432/database?charset=utf8&connect_timeout=5&sslmode=1',
14+
// ...
15+
];
16+
17+
// ...
18+
}

0 commit comments

Comments
 (0)