Convert PDOException to DBError in _fetch()

This commit is contained in:
Kijin Sung 2020-12-26 17:14:11 +09:00
parent 3dc27f37b7
commit afcc25bd50

View file

@ -477,17 +477,24 @@ class DB
return $stmt;
}
$result = array();
$index = $last_index;
$step = $last_index !== 0 ? -1 : 1;
while ($row = $stmt->fetchObject())
try
{
$result[$index] = $row;
$index += $step;
$result = array();
$index = $last_index;
$step = $last_index !== 0 ? -1 : 1;
while ($row = $stmt->fetchObject())
{
$result[$index] = $row;
$index += $step;
}
$stmt->closeCursor();
}
catch (\PDOException $e)
{
throw new Exceptions\DBError($e->getMessage(), 0, $e);
}
$stmt->closeCursor();
if ($result_type === 'auto' && $last_index === 0 && count($result) === 1)
{