Skip to content

[Lock] Fix code example for Doctrine based stores #16501

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

Merged
merged 1 commit into from
Feb 18, 2022
Merged
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
14 changes: 7 additions & 7 deletions components/lock.rst
Original file line number Diff line number Diff line change
Expand Up @@ -507,11 +507,11 @@ The DoctrineDbalStore saves locks in an SQL database. It is identical to PdoStor
but requires a `Doctrine DBAL Connection`_, or a `Doctrine DBAL URL`_. This store
does not support blocking, and expects a TTL to avoid stalled locks::

use Symfony\Component\Lock\Store\PdoStore;
use Symfony\Component\Lock\Store\DoctrineDbalStore;

// a PDO, a Doctrine DBAL connection or DSN for lazy connecting through PDO
// a Doctrine DBAL connection or DSN
$connectionOrURL = 'mysql://myuser:[email protected]/app';
$store = new PdoStore($connectionOrURL);
$store = new DoctrineDbalStore($connectionOrURL);

.. note::

Expand Down Expand Up @@ -566,11 +566,11 @@ The DoctrineDbalPostgreSqlStore uses `Advisory Locks`_ provided by PostgreSQL.
It is identical to PostgreSqlStore but requires a `Doctrine DBAL Connection`_ or
a `Doctrine DBAL URL`_. It supports native blocking, as well as sharing locks::

use Symfony\Component\Lock\Store\PostgreSqlStore;
use Symfony\Component\Lock\Store\DoctrineDbalPostgreSqlStore;

// a PDO instance or DSN for lazy connecting through PDO
$databaseConnectionOrDSN = 'pgsql:host=localhost;port=5634;dbname=lock';
$store = new PostgreSqlStore($databaseConnectionOrDSN, ['db_username' => 'myuser', 'db_password' => 'mypassword']);
// a Doctrine Connection or DSN
$databaseConnectionOrDSN = 'postgresql+advisory://myuser:[email protected]:5634/lock';
$store = new DoctrineDbalPostgreSqlStore($databaseConnectionOrDSN);

In opposite to the ``DoctrineDbalStore``, the ``DoctrineDbalPostgreSqlStore`` does not need a table to
store locks and does not expire.
Expand Down