You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
1.1 KiB
41 lines
1.1 KiB
<?php
|
|
class Connection extends SQLite3
|
|
{
|
|
private $stmt;
|
|
private $result;
|
|
function __construct($dsn)
|
|
{
|
|
$this->open($dsn);
|
|
$this->enableExceptions(true);
|
|
}
|
|
|
|
public function executeQuery(string $query, array $parameters = []): bool
|
|
{
|
|
$this->stmt = parent::prepare($query);
|
|
foreach ($parameters as $name => $value) {
|
|
$this->stmt->bindValue($name, $value[0], $value[1]);
|
|
}
|
|
$this->result = $this->stmt->execute();
|
|
if ($this->result == false) {
|
|
$this->result->finalize();
|
|
return false;
|
|
} else {
|
|
$this->result->finalize();
|
|
return true;
|
|
}
|
|
}
|
|
|
|
public function getResults(): array
|
|
{
|
|
$resultArray = $this->result->fetchArray(SQLITE3_ASSOC);
|
|
$multiArray = array();
|
|
while($resultArray != false){ //read next row
|
|
$multiArray[]=$resultArray;
|
|
$resultArray = $this->result->fetchArray(SQLITE3_ASSOC); //insert all rows to $multiArray
|
|
}
|
|
if ($multiArray == NULL)
|
|
return array();
|
|
else
|
|
return $multiArray;
|
|
}
|
|
} |