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 all commits
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
16 changes: 16 additions & 0 deletions user_guide_src/source/database/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,19 @@ Explanation of Values:
etc.) not all values will be needed. For example, when using ``SQLite3`` you
will not need to supply a username or password, and the database name
will be the path to your database file.

MySQLi
======

hostname
--------

Configuring a 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
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',
// ...
'DBDriver' => 'MySQLi',
// ...
];

// ...
}