catch exceptions when using PDO directly

This commit is contained in:
Christian Flothmann 2019-11-16 10:57:45 +01:00
parent d863fc2b4b
commit 5c1f5594f5
1 changed files with 16 additions and 0 deletions

View File

@ -159,6 +159,8 @@ trait PdoTrait
$delete = $this->getConnection()->prepare($deleteSql);
} catch (TableNotFoundException $e) {
return true;
} catch (\PDOException $e) {
return true;
}
$delete->bindValue(':time', time(), \PDO::PARAM_INT);
@ -169,6 +171,8 @@ trait PdoTrait
return $delete->execute();
} catch (TableNotFoundException $e) {
return true;
} catch (\PDOException $e) {
return true;
}
}
@ -244,6 +248,7 @@ trait PdoTrait
try {
$conn->exec($sql);
} catch (TableNotFoundException $e) {
} catch (\PDOException $e) {
}
return true;
@ -260,6 +265,7 @@ trait PdoTrait
$stmt = $this->getConnection()->prepare($sql);
$stmt->execute(array_values($ids));
} catch (TableNotFoundException $e) {
} catch (\PDOException $e) {
}
return true;
@ -316,6 +322,11 @@ trait PdoTrait
$this->createTable();
}
$stmt = $conn->prepare($sql);
} catch (\PDOException $e) {
if (!$conn->inTransaction() || \in_array($this->driver, ['pgsql', 'sqlite', 'sqlsrv'], true)) {
$this->createTable();
}
$stmt = $conn->prepare($sql);
}
if ('sqlsrv' === $driver || 'oci' === $driver) {
@ -350,6 +361,11 @@ trait PdoTrait
$this->createTable();
}
$stmt->execute();
} catch (\PDOException $e) {
if (!$conn->inTransaction() || \in_array($this->driver, ['pgsql', 'sqlite', 'sqlsrv'], true)) {
$this->createTable();
}
$stmt->execute();
}
if (null === $driver && !$stmt->rowCount()) {
try {