Skip to content

Commit e381a66

Browse files
committed
minor #16501 [Lock] Fix code example for Doctrine based stores (Jibbarth)
This PR was merged into the 5.4 branch. Discussion ---------- [Lock] Fix code example for Doctrine based stores Just noticed examples code for DoctrineDbalStore and DoctrineDbalPostgreSqlStore still used the old Pdo*Store. Commits ------- 9829b13 [Lock] Fix code example for Doctrine based stores
2 parents fc99261 + 9829b13 commit e381a66

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

components/lock.rst

+7-7
Original file line numberDiff line numberDiff line change
@@ -507,11 +507,11 @@ The DoctrineDbalStore saves locks in an SQL database. It is identical to PdoStor
507507
but requires a `Doctrine DBAL Connection`_, or a `Doctrine DBAL URL`_. This store
508508
does not support blocking, and expects a TTL to avoid stalled locks::
509509

510-
use Symfony\Component\Lock\Store\PdoStore;
510+
use Symfony\Component\Lock\Store\DoctrineDbalStore;
511511

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

516516
.. note::
517517

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

569-
use Symfony\Component\Lock\Store\PostgreSqlStore;
569+
use Symfony\Component\Lock\Store\DoctrineDbalPostgreSqlStore;
570570

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

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

0 commit comments

Comments
 (0)