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.
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:
use YandexCloud\Ydb\Ydb; $config = [ // ... ]; $ydb = new Ydb($config);
App code snippet for creating a session:
// obtaining the Table service $table = $ydb->table(); // obtaining a session $session = $table->session();