WIP on new option library

This commit is contained in:
2024-07-28 19:21:37 -04:00
parent 57d8f9ddc1
commit 4d764cbb3f
4 changed files with 65 additions and 15 deletions

View File

@@ -8,11 +8,11 @@ declare(strict_types=1);
namespace BitBadger\PDODocument;
use BitBadger\InspiredByFSharp\Option;
use BitBadger\PDODocument\Mapper\Mapper;
use PDO;
use PDOException;
use PDOStatement;
use PhpOption\{None, Option, Some};
/**
* Functions to execute custom queries
@@ -106,7 +106,7 @@ class Custom
{
try {
$stmt = &self::runQuery("$query LIMIT 1", $parameters);
return ($first = $stmt->fetch(PDO::FETCH_ASSOC)) ? Some::create($mapper->map($first)) : None::create();
return ($first = $stmt->fetch(PDO::FETCH_ASSOC)) ? Option::Some($mapper->map($first)) : Option::None();
} finally {
$stmt = null;
}