App in PHP
This page contains a detailed description of the code of a test app that is available as part of the YDB PHP SDK.
Note
The article is being updated.
Initializing a database connection
To interact with YDB, create an instance of the driver, client, and session:
- The YDB driver lets the app and YDB interact at the transport layer. The driver must exist throughout the YDB access lifecycle and be initialized before creating a client or session.
- The YDB client runs on top of the YDB driver and enables the handling of entities and transactions.
- The YDB session contains information about executed transactions and prepared queries, and is part of the YDB client context.
App code snippet for driver initialization:
1. <?php
3. use YandexCloud\Ydb\Ydb;
5. $config = [
6. // ...
7. ];
9. $ydb = new Ydb($config);

App code snippet for creating a session:
1. // obtaining the Table service
2. $table = $ydb->table();
4. // obtaining a session
5. $session = $table->session();

