Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
b964bd65fe | |||
cc7cd638e3 |
@ -31,18 +31,34 @@ class ResultSet implements RSInterface
|
|||||||
|
|
||||||
public function getAsArray(): array
|
public function getAsArray(): array
|
||||||
{
|
{
|
||||||
return $this->getStatement()->fetchAll(PDO::FETCH_ASSOC);
|
$rs = $this->getStatement()->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
if (!$rs) {
|
||||||
|
throw new \PDOException("No results found.");
|
||||||
|
}
|
||||||
|
return $rs;
|
||||||
}
|
}
|
||||||
public function getAsObject(): array
|
public function getAsObject(): array
|
||||||
{
|
{
|
||||||
return $this->getStatement()->fetchAll(PDO::FETCH_OBJ);
|
$rs = $this->getStatement()->fetchAll(PDO::FETCH_OBJ);
|
||||||
|
if (!$rs) {
|
||||||
|
throw new \PDOException("No results found.");
|
||||||
|
}
|
||||||
|
return $rs;
|
||||||
}
|
}
|
||||||
public function getFirstAsArray(): array
|
public function getFirstAsArray(): array
|
||||||
{
|
{
|
||||||
return $this->getStatement()->fetch(PDO::FETCH_ASSOC);
|
$rs = $this->getStatement()->fetch(PDO::FETCH_ASSOC);
|
||||||
|
if (!$rs or count($rs) === 0) {
|
||||||
|
throw new \PDOException("No results found.");
|
||||||
|
}
|
||||||
|
return $rs;
|
||||||
}
|
}
|
||||||
public function getFirstAsObject(): object
|
public function getFirstAsObject(): object
|
||||||
{
|
{
|
||||||
return $this->getStatement()->fetch(PDO::FETCH_OBJ);
|
$rs = $this->getStatement()->fetch(PDO::FETCH_OBJ);
|
||||||
|
if (!$rs or count($rs) === 0) {
|
||||||
|
throw new \PDOException("No results found.");
|
||||||
|
}
|
||||||
|
return $rs;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user