Compare commits
1 Commits
2.2.1
...
9ec9fdd731
Author | SHA1 | Date | |
---|---|---|---|
9ec9fdd731 |
@ -11,10 +11,5 @@
|
||||
"email": "aldarien85@gmail.com"
|
||||
}
|
||||
],
|
||||
"require": {},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"ProVM\\": "src/"
|
||||
}
|
||||
}
|
||||
"require": {}
|
||||
}
|
||||
|
@ -9,6 +9,5 @@ interface ResultSet
|
||||
public function execute(array $values): ResultSet;
|
||||
public function getAsArray(): array;
|
||||
public function getAsObject(): array;
|
||||
public function getFirstAsArray(): array;
|
||||
public function getFirstAsObject(): object;
|
||||
public function getFirst(): mixed;
|
||||
}
|
||||
|
@ -1,11 +0,0 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
@ -4,7 +4,6 @@ namespace ProVM\Database;
|
||||
use PDO;
|
||||
use PDOStatement;
|
||||
use ProVM\Concept\Database\ResultSet as RSInterface;
|
||||
use ProVM\Exception\BlankResult;
|
||||
|
||||
class ResultSet implements RSInterface
|
||||
{
|
||||
@ -32,34 +31,14 @@ class ResultSet implements RSInterface
|
||||
|
||||
public function getAsArray(): array
|
||||
{
|
||||
$rs = $this->getStatement()->fetchAll(PDO::FETCH_ASSOC);
|
||||
if (!$rs) {
|
||||
throw new BlankResult();
|
||||
}
|
||||
return $rs;
|
||||
return $this->getStatement()->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
public function getAsObject(): array
|
||||
{
|
||||
$rs = $this->getStatement()->fetchAll(PDO::FETCH_OBJ);
|
||||
if (!$rs) {
|
||||
throw new BlankResult();
|
||||
}
|
||||
return $rs;
|
||||
return $this->getStatement()->fetchAll(PDO::FETCH_OBJ);
|
||||
}
|
||||
public function getFirstAsArray(): array
|
||||
public function getFirst(): mixed
|
||||
{
|
||||
$rs = $this->getStatement()->fetch(PDO::FETCH_ASSOC);
|
||||
if (!$rs or count($rs) === 0) {
|
||||
throw new BlankResult();
|
||||
}
|
||||
return $rs;
|
||||
}
|
||||
public function getFirstAsObject(): object
|
||||
{
|
||||
$rs = $this->getStatement()->fetch(PDO::FETCH_OBJ);
|
||||
if (!$rs or count($rs) === 0) {
|
||||
throw new BlankResult();
|
||||
}
|
||||
return $rs;
|
||||
return $this->getStatement()->fetch(PDO::FETCH_OBJ);
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +0,0 @@
|
||||
<?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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user