Implementations
This commit is contained in:
44
src/Database/ResultSet.php
Normal file
44
src/Database/ResultSet.php
Normal file
@ -0,0 +1,44 @@
|
||||
<?php
|
||||
namespace ProVM\Database;
|
||||
|
||||
use PDO;
|
||||
use PDOStatement;
|
||||
use ProVM\Concept\Database\ResultSet as RSInterface;
|
||||
|
||||
class ResultSet implements RSInterface
|
||||
{
|
||||
public function __construct(PDOStatement $statement)
|
||||
{
|
||||
$this->setStatement($statement);
|
||||
}
|
||||
|
||||
protected PDOStatement $statement;
|
||||
public function setStatement(PDOStatement $statement): RSInterface
|
||||
{
|
||||
$this->statement = $statement;
|
||||
return $this;
|
||||
}
|
||||
public function getStatement(): PDOStatement
|
||||
{
|
||||
return $this->statement;
|
||||
}
|
||||
|
||||
public function execute(array $values): RSInterface
|
||||
{
|
||||
$this->getStatement()->execute($values);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAsArray(): array
|
||||
{
|
||||
return $this->getStatement()->fetchAll(PDO::FETCH_ASSOC);
|
||||
}
|
||||
public function getAsObject(): array
|
||||
{
|
||||
return $this->getStatement()->fetchAll(PDO::FETCH_OBJ);
|
||||
}
|
||||
public function getFirst(): mixed
|
||||
{
|
||||
return $this->getStatement()->fetch(PDO::FETCH_OBJ);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user