4 Commits
2.1.1 ... 2.2.1

Author SHA1 Message Date
fb37211f7d Merge branch 'develop' into release 2022-12-22 22:25:04 -03:00
a326904825 Use exception in ResultSet 2022-12-22 22:24:55 -03:00
816d8f7b9c Merge branch 'develop' into release 2022-12-22 18:59:07 -03:00
2c6c0e6e55 Added exceptions with base numbering 300 2022-12-22 18:58:26 -03:00
3 changed files with 31 additions and 4 deletions

View File

@ -0,0 +1,11 @@
<?php
namespace ProVM\Database;
class Exception extends \Exception
{
public function __construct(string $message = "", int $code = 0, ?Throwable $previous = null)
{
$code += 300;
parent::__construct($message, $code, $previous);
}
}

View File

@ -4,6 +4,7 @@ namespace ProVM\Database;
use PDO;
use PDOStatement;
use ProVM\Concept\Database\ResultSet as RSInterface;
use ProVM\Exception\BlankResult;
class ResultSet implements RSInterface
{
@ -33,7 +34,7 @@ class ResultSet implements RSInterface
{
$rs = $this->getStatement()->fetchAll(PDO::FETCH_ASSOC);
if (!$rs) {
throw new \PDOException("No results found.");
throw new BlankResult();
}
return $rs;
}
@ -41,7 +42,7 @@ class ResultSet implements RSInterface
{
$rs = $this->getStatement()->fetchAll(PDO::FETCH_OBJ);
if (!$rs) {
throw new \PDOException("No results found.");
throw new BlankResult();
}
return $rs;
}
@ -49,7 +50,7 @@ class ResultSet implements RSInterface
{
$rs = $this->getStatement()->fetch(PDO::FETCH_ASSOC);
if (!$rs or count($rs) === 0) {
throw new \PDOException("No results found.");
throw new BlankResult();
}
return $rs;
}
@ -57,7 +58,7 @@ class ResultSet implements RSInterface
{
$rs = $this->getStatement()->fetch(PDO::FETCH_OBJ);
if (!$rs or count($rs) === 0) {
throw new \PDOException("No results found.");
throw new BlankResult();
}
return $rs;
}

View File

@ -0,0 +1,15 @@
<?php
namespace ProVM\Exception;
use ProVM\Database\Exception;
use Throwable;
class BlankResult extends Exception
{
public function __construct(?Throwable $previous = null)
{
$message = "No results found";
$code = 0;
parent::__construct($message, $code, $previous);
}
}