Skip to content

Commit

Permalink
Add full example
Browse files Browse the repository at this point in the history
  • Loading branch information
hlcianfagna authored Jan 10, 2024
1 parent 052eab8 commit 2ae62e3
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions docs/connect.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,23 @@ by setting the connection's ``CRATE_ATTR_SSL_MODE`` attribute:

.. code-block:: php
$connection->setAttribute(PDOCrateDB::CRATE_ATTR_SSL_MODE, PDOCrateDB::CRATE_ATTR_SSL_MODE_REQUIRED);
<?php
require __DIR__ . '/vendor/autoload.php';
use Crate\PDO\PDOCrateDB;
$dsn = 'crate:yourcluster.yourdomain.com:4200';
$user = 'user1';
echo "Enter pwd for the user1 account: ";
$password = rtrim(fgets(STDIN));
$options = null;
$connection = new PDOCrateDB($dsn, $user, $password, $options);
$connection->setAttribute(PDOCrateDB::CRATE_ATTR_SSL_MODE, PDOCrateDB::CRATE_ATTR_SSL_MODE_REQUIRED);
$stmt = $connection->prepare('SELECT mountain FROM sys.summits LIMIT 1;');
$stmt->execute();
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($rows as $row) {
print_r($row);
}
?>
If this is not configured you will see the following error message:
``cURL error 52: Empty reply from server``
Expand Down Expand Up @@ -155,7 +171,7 @@ Driver specific constants

The CrateDB driver provides number of ``PDO`` attribute class constants.

``PDO::CRATE_ATTR_DEFAULT_SCHEMA`` (string)
``PDOCrateDB::CRATE_ATTR_DEFAULT_SCHEMA`` (string)
The default schema for the PDO connection.

.. TIP::
Expand All @@ -165,7 +181,7 @@ The CrateDB driver provides number of ``PDO`` attribute class constants.

However, you can query any schema you like by specifying it in the query.

``PDO::CRATE_ATTR_SSL_MODE`` (int) named attribute
``PDOCrateDB::CRATE_ATTR_SSL_MODE`` (int) named attribute
The connection SSL mode.

Accepted values:
Expand All @@ -179,19 +195,19 @@ The CrateDB driver provides number of ``PDO`` attribute class constants.
``CRATE_ATTR_SSL_MODE_REQUIRED``
Enable SSL mode, and perform host verification.

``PDO::CRATE_ATTR_SSL_KEY_PATH`` (string)
``PDOCrateDB::CRATE_ATTR_SSL_KEY_PATH`` (string)
The path to an SSL client key file.

``PDO::CRATE_ATTR_SSL_KEY_PASSWORD`` (string)
``PDOCrateDB::CRATE_ATTR_SSL_KEY_PASSWORD`` (string)
The SSL client key file password.

``PDO::CRATE_ATTR_SSL_CERT_PATH`` (string)
``PDOCrateDB::CRATE_ATTR_SSL_CERT_PATH`` (string)
The path to an SSL client certificate file.

``PDO::CRATE_ATTR_SSL_CERT_PASSWORD`` (string)
``PDOCrateDB::CRATE_ATTR_SSL_CERT_PASSWORD`` (string)
The SSL client certificate file password.

``PDO::CRATE_ATTR_SSL_CA_PATH`` (string)
``PDOCrateDB::CRATE_ATTR_SSL_CA_PATH`` (string)
The path to an SSL *Certificate Authority* (CA) certificate file.

.. SEEALSO::
Expand Down

0 comments on commit 2ae62e3

Please sign in to comment.