Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: update database connection with information on how to connect to a MySQL server over a socket #8629

Merged
merged 4 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions user_guide_src/source/database/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ add the config variables as a query string:
database character set), which are present in the rest of the configuration
fields, CodeIgniter will append them.

Configuring a MySQL socket connection
-------------------------------------

To connect to a MySQL server over a filesystem socket, the path to the socket should be specified in
the ``'hostname'`` setting. CodeIgniter's MySQLi driver will notice this and configure the
connection properly.

.. literalinclude:: configuration/011.php
:lines: 11-18

Failovers
---------

Expand Down
21 changes: 21 additions & 0 deletions user_guide_src/source/database/configuration/011.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

namespace Config;

use CodeIgniter\Database\Config;

class Database extends Config
{
// ...

// MySQLi over a socket
public array $default = [
// ...
'hostname' => '/cloudsql/toolbox-tests:europe-north1:toolbox-db"',
tangix marked this conversation as resolved.
Show resolved Hide resolved
// ...
'DBDriver' => 'MySQLi',
// ...
];

// ...
}