Initial SQLite development #1

Merged
danieljsummers merged 25 commits from develop into main 2024-06-08 23:58:45 +00:00
Showing only changes of commit cecbb51414 - Show all commits

View File

@ -91,8 +91,8 @@ class Custom
{ {
try { try {
$stmt = self::runQuery($query, $parameters, is_null($pdo) ? $actualPDO = Configuration::dbConn() : $pdo); $stmt = self::runQuery($query, $parameters, is_null($pdo) ? $actualPDO = Configuration::dbConn() : $pdo);
$stmt = null;
} finally { } finally {
$stmt = null;
if (isset($actualPDO)) $actualPDO = null; if (isset($actualPDO)) $actualPDO = null;
} }
} }
@ -110,11 +110,12 @@ class Custom
*/ */
public static function scalar(string $query, array $parameters, Mapper $mapper, ?PDO $pdo = null): mixed public static function scalar(string $query, array $parameters, Mapper $mapper, ?PDO $pdo = null): mixed
{ {
$stmt = self::runQuery($query, $parameters, $pdo ?? Configuration::dbConn()); try {
if ($stmt->rowCount() > 0) { $stmt = self::runQuery($query, $parameters, is_null($pdo) ? $actualPDO = Configuration::dbConn() : $pdo);
$first = $stmt->fetch(PDO::FETCH_NUM); return ($first = $stmt->fetch(PDO::FETCH_NUM)) ? $mapper->map($first) : false;
return $first ? $mapper->map($first) : false; } finally {
$stmt = null;
if (isset($actualPDO)) $actualPDO = null;
} }
return false;
} }
} }