Skip to content

Commit

Permalink
Merge pull request #8629 from tangix/update-db-docs-socket
Browse files Browse the repository at this point in the history
docs: update database connection with information on how to connect to a MySQL server over a socket
  • Loading branch information
kenjis authored Mar 18, 2024
2 parents b8adef6 + 2ae6628 commit fd6d674
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
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',
// ...
];

// ...
}

0 comments on commit fd6d674

Please sign in to comment.