6 Commits
2.0.1 ... 2.1.1

Author SHA1 Message Date
b964bd65fe Merge branch 'develop' into release 2022-09-12 21:54:29 -03:00
cc7cd638e3 Added check for empty or false results. 2022-09-12 21:54:20 -03:00
ac9b141928 Merge branch 'develop' into release 2022-09-12 21:45:22 -03:00
758ff0e282 Added more detail in obtaining first result 2022-09-12 21:45:14 -03:00
d5fde83afb FIX 2022-09-09 11:19:11 -04:00
6dda8e1515 FIX 2022-09-09 11:18:36 -04:00
3 changed files with 29 additions and 6 deletions

View File

@ -13,6 +13,8 @@
],
"require": {},
"autoload": {
"ProVM\\": "src/"
"psr-4": {
"ProVM\\": "src/"
}
}
}

View File

@ -9,5 +9,6 @@ interface ResultSet
public function execute(array $values): ResultSet;
public function getAsArray(): array;
public function getAsObject(): array;
public function getFirst(): mixed;
public function getFirstAsArray(): array;
public function getFirstAsObject(): object;
}

View File

@ -31,14 +31,34 @@ class ResultSet implements RSInterface
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
{
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 getFirst(): mixed
public function getFirstAsArray(): array
{
return $this->getStatement()->fetch(PDO::FETCH_OBJ);
$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
{
$rs = $this->getStatement()->fetch(PDO::FETCH_OBJ);
if (!$rs or count($rs) === 0) {
throw new \PDOException("No results found.");
}
return $rs;
}
}