catch exceptions when using PDO directly
This commit is contained in:
parent
d863fc2b4b
commit
5c1f5594f5
|
@ -159,6 +159,8 @@ trait PdoTrait
|
||||||
$delete = $this->getConnection()->prepare($deleteSql);
|
$delete = $this->getConnection()->prepare($deleteSql);
|
||||||
} catch (TableNotFoundException $e) {
|
} catch (TableNotFoundException $e) {
|
||||||
return true;
|
return true;
|
||||||
|
} catch (\PDOException $e) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
$delete->bindValue(':time', time(), \PDO::PARAM_INT);
|
$delete->bindValue(':time', time(), \PDO::PARAM_INT);
|
||||||
|
|
||||||
|
@ -169,6 +171,8 @@ trait PdoTrait
|
||||||
return $delete->execute();
|
return $delete->execute();
|
||||||
} catch (TableNotFoundException $e) {
|
} catch (TableNotFoundException $e) {
|
||||||
return true;
|
return true;
|
||||||
|
} catch (\PDOException $e) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,6 +248,7 @@ trait PdoTrait
|
||||||
try {
|
try {
|
||||||
$conn->exec($sql);
|
$conn->exec($sql);
|
||||||
} catch (TableNotFoundException $e) {
|
} catch (TableNotFoundException $e) {
|
||||||
|
} catch (\PDOException $e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -260,6 +265,7 @@ trait PdoTrait
|
||||||
$stmt = $this->getConnection()->prepare($sql);
|
$stmt = $this->getConnection()->prepare($sql);
|
||||||
$stmt->execute(array_values($ids));
|
$stmt->execute(array_values($ids));
|
||||||
} catch (TableNotFoundException $e) {
|
} catch (TableNotFoundException $e) {
|
||||||
|
} catch (\PDOException $e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -316,6 +322,11 @@ trait PdoTrait
|
||||||
$this->createTable();
|
$this->createTable();
|
||||||
}
|
}
|
||||||
$stmt = $conn->prepare($sql);
|
$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) {
|
if ('sqlsrv' === $driver || 'oci' === $driver) {
|
||||||
|
@ -350,6 +361,11 @@ trait PdoTrait
|
||||||
$this->createTable();
|
$this->createTable();
|
||||||
}
|
}
|
||||||
$stmt->execute();
|
$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()) {
|
if (null === $driver && !$stmt->rowCount()) {
|
||||||
try {
|
try {
|
||||||
|
|
Reference in New Issue