Skip to content

Commit

Permalink
Merge pull request #3 from mybuilder/pdo-timeout-env
Browse files Browse the repository at this point in the history
Add `PROPEL_PDO_CONNECTION_TIMEOUT` env variable
  • Loading branch information
eddmann authored Oct 27, 2021
2 parents 2f1619f + c3058fa commit 527c4db
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions runtime/lib/Propel.php
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,13 @@ public static function initConnection($conparams, $name, $defaultClass = Propel:
$con = new $classname($dsn, $user, $password, $driver_options);
$con->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$con->setAttribute(PropelPDO::PROPEL_ATTR_CONNECTION_NAME, $name);

// With the PropelBundle Symfony integration there is no way to correctly specify PDO attributes.
// The configuration schema requires a scalar value, however Propel requires a keyed 'value' array.
// This allows us to specify the timeout within the runtime environment (i.e for Lambda).
if ($connectionTimeout = \getenv('PROPEL_PDO_CONNECTION_TIMEOUT')) {
$con->setAttribute(\PDO::ATTR_TIMEOUT, $connectionTimeout);
}
} catch (PDOException $e) {
throw new PropelException("Unable to open PDO connection", $e);
}
Expand Down

0 comments on commit 527c4db

Please sign in to comment.