Improved reconnect
This commit is contained in:
parent
0e49fb7b63
commit
5a95c60b45
|
@ -52,10 +52,11 @@ services:
|
|||
- ./phpunit.xml:/usr/src/code/phpunit.xml
|
||||
- ./tests:/usr/src/code/tests
|
||||
- ./app:/usr/src/code/app
|
||||
# - ./vendor:/usr/src/code/vendor
|
||||
- ./vendor:/usr/src/code/vendor
|
||||
- ./docs:/usr/src/code/docs
|
||||
- ./public:/usr/src/code/public
|
||||
- ./src:/usr/src/code/src
|
||||
- ./debug:/tmp
|
||||
depends_on:
|
||||
- mariadb
|
||||
- redis
|
||||
|
@ -198,6 +199,13 @@ services:
|
|||
- GH_CLIENT_SECRET=9e0081062367a2134e7f2ea95ba1a32d08b6c8ab
|
||||
- GH_ORGS=appwrite
|
||||
|
||||
webgrind:
|
||||
image: 'jokkedk/webgrind:latest'
|
||||
volumes:
|
||||
- './debug:/tmp'
|
||||
ports:
|
||||
- '3001:80'
|
||||
|
||||
networks:
|
||||
gateway:
|
||||
appwrite:
|
||||
|
|
|
@ -61,8 +61,6 @@ class PDO extends PDONative
|
|||
|
||||
public function reconnect()
|
||||
{
|
||||
sleep(3);
|
||||
|
||||
$this->pdo = new PDONative($this->dsn, $this->username, $this->passwd, $this->options);
|
||||
|
||||
// Connection settings
|
||||
|
|
|
@ -12,6 +12,21 @@ class PDOStatement extends PDOStatementNative
|
|||
*/
|
||||
protected $pdo;
|
||||
|
||||
/**
|
||||
* Params
|
||||
*/
|
||||
protected $params = [];
|
||||
|
||||
/**
|
||||
* Values
|
||||
*/
|
||||
protected $values = [];
|
||||
|
||||
/**
|
||||
* Columns
|
||||
*/
|
||||
protected $columns = [];
|
||||
|
||||
/**
|
||||
* @var PDOStatementNative
|
||||
*/
|
||||
|
@ -19,12 +34,14 @@ class PDOStatement extends PDOStatementNative
|
|||
|
||||
public function __construct(PDO &$pdo, PDOStatementNative $PDOStatement)
|
||||
{
|
||||
$this->pdo = $pdo;
|
||||
$this->pdo = &$pdo;
|
||||
$this->PDOStatement = $PDOStatement;
|
||||
}
|
||||
|
||||
public function bindValue($parameter, $value, $data_type = PDONative::PARAM_STR)
|
||||
{
|
||||
$this->values[$parameter] = ['value' => $value, 'data_type' => $data_type];
|
||||
|
||||
$result = $this->PDOStatement->bindValue($parameter, $value, $data_type);
|
||||
|
||||
return $result;
|
||||
|
@ -32,6 +49,8 @@ class PDOStatement extends PDOStatementNative
|
|||
|
||||
public function bindParam($parameter, &$variable, $data_type = PDONative::PARAM_STR, $length = null, $driver_options = null)
|
||||
{
|
||||
$this->params[$parameter] = ['value' => &$variable, 'data_type' => $data_type, 'length' => $length, 'driver_options' => $driver_options];
|
||||
|
||||
$result = $this->PDOStatement->bindParam($parameter, $variable, $data_type, $length, $driver_options);
|
||||
|
||||
return $result;
|
||||
|
@ -39,6 +58,8 @@ class PDOStatement extends PDOStatementNative
|
|||
|
||||
public function bindColumn($column, &$param, $type = null, $maxlen = null, $driverdata = null)
|
||||
{
|
||||
$this->columns[$column] = ['param' => &$param, 'type' => $type, 'maxlen' => $maxlen, 'driverdata' => $driverdata];
|
||||
|
||||
$result = $this->PDOStatement->bindColumn($column, $param, $type, $maxlen, $driverdata);
|
||||
|
||||
return $result;
|
||||
|
@ -50,7 +71,19 @@ class PDOStatement extends PDOStatementNative
|
|||
$result = $this->PDOStatement->execute($input_parameters);
|
||||
} catch (\Throwable $th) {
|
||||
$this->pdo = $this->pdo->reconnect();
|
||||
//$this->PDOStatement = $this->pdo->prepare($this->PDOStatement->queryString, []);
|
||||
$this->PDOStatement = $this->pdo->prepare($this->PDOStatement->queryString, []);
|
||||
|
||||
foreach($this->values as $key => $set) {
|
||||
$this->PDOStatement->bindValue($key, $set['value'], $set['data_type']);
|
||||
}
|
||||
|
||||
foreach($this->params as $key => $set) {
|
||||
$this->PDOStatement->bindParam($key, $set['variable'], $set['data_type'], $set['length'], $set['driver_options']);
|
||||
}
|
||||
|
||||
foreach($this->columns as $key => $set) {
|
||||
$this->PDOStatement->bindColumn($key, $set['param'], $set['type'], $set['maxlen'], $set['driverdata']);
|
||||
}
|
||||
|
||||
$result = $this->PDOStatement->execute($input_parameters);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue