Connection persistency
This commit is contained in:
parent
5a32260dd2
commit
457fffc692
5 changed files with 11 additions and 8 deletions
|
@ -305,7 +305,7 @@ App::error(function ($error, $utopia, $request, $response, $project) {
|
||||||
$message = 'Server Error';
|
$message = 'Server Error';
|
||||||
}
|
}
|
||||||
|
|
||||||
$_SERVER = []; // Reset before reporting to error log to avoid keys being compromised
|
//$_SERVER = []; // Reset before reporting to error log to avoid keys being compromised
|
||||||
|
|
||||||
$output = ((App::isDevelopment())) ? [
|
$output = ((App::isDevelopment())) ? [
|
||||||
'message' => $error->getMessage(),
|
'message' => $error->getMessage(),
|
||||||
|
|
|
@ -122,7 +122,6 @@ $register->set('statsd', function () { // Register DB connection
|
||||||
});
|
});
|
||||||
$register->set('cache', function () { // Register cache connection
|
$register->set('cache', function () { // Register cache connection
|
||||||
$redis = new Redis();
|
$redis = new Redis();
|
||||||
|
|
||||||
$redis->pconnect(App::getEnv('_APP_REDIS_HOST', ''),
|
$redis->pconnect(App::getEnv('_APP_REDIS_HOST', ''),
|
||||||
App::getEnv('_APP_REDIS_PORT', ''));
|
App::getEnv('_APP_REDIS_PORT', ''));
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Utopia\Locale\Locale;
|
|
||||||
|
|
||||||
$protocol = $this->getParam('protocol', '');
|
$protocol = $this->getParam('protocol', '');
|
||||||
$domain = $this->getParam('domain', '');
|
$domain = $this->getParam('domain', '');
|
||||||
$platforms = $this->getParam('platforms', []);
|
$platforms = $this->getParam('platforms', []);
|
||||||
|
|
|
@ -51,7 +51,7 @@ class PDO
|
||||||
|
|
||||||
public function prepare($statement, array $driver_options = [])
|
public function prepare($statement, array $driver_options = [])
|
||||||
{
|
{
|
||||||
return new PDOStatement($this->pdo, $this->pdo->prepare($statement, $driver_options));
|
return new PDOStatement($this, $this->pdo->prepare($statement, $driver_options));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function quote($string, $parameter_type = PDONative::PARAM_STR)
|
public function quote($string, $parameter_type = PDONative::PARAM_STR)
|
||||||
|
|
|
@ -8,7 +8,7 @@ use PDOStatement as PDOStatementNative;
|
||||||
class PDOStatement
|
class PDOStatement
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @var PDONative
|
* @var PDO
|
||||||
*/
|
*/
|
||||||
protected $pdo;
|
protected $pdo;
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ class PDOStatement
|
||||||
*/
|
*/
|
||||||
protected $PDOStatement;
|
protected $PDOStatement;
|
||||||
|
|
||||||
public function __construct(PDONative &$pdo, PDOStatementNative $PDOStatement)
|
public function __construct(PDO &$pdo, PDOStatementNative $PDOStatement)
|
||||||
{
|
{
|
||||||
$this->pdo = $pdo;
|
$this->pdo = $pdo;
|
||||||
$this->PDOStatement = $PDOStatement;
|
$this->PDOStatement = $PDOStatement;
|
||||||
|
@ -46,7 +46,13 @@ class PDOStatement
|
||||||
|
|
||||||
public function execute($input_parameters = null)
|
public function execute($input_parameters = null)
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
$result = $this->PDOStatement->execute($input_parameters);
|
$result = $this->PDOStatement->execute($input_parameters);
|
||||||
|
} catch (\Throwable $th) {
|
||||||
|
// throw new Exception('My Error: ' .$th->getMessage());
|
||||||
|
$this->pdo->reconnect();
|
||||||
|
$result = $this->PDOStatement->execute($input_parameters);
|
||||||
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue