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.
42 lines
1.3 KiB
42 lines
1.3 KiB
<?php
|
|
|
|
class Connection extends PDO {
|
|
private $stmt;
|
|
public function __construct(string $dsn) {
|
|
parent::__construct($dsn);
|
|
echo "connection";
|
|
$this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); }
|
|
|
|
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]); }
|
|
return $this->stmt->execute(); }
|
|
public function getResults(): array {
|
|
return $this->stmt->fetchall();
|
|
}
|
|
}
|
|
|
|
// class Connection extends SQLite3
|
|
// {
|
|
// private $stmt;
|
|
// private $result;
|
|
// function __construct($dsn)
|
|
// {
|
|
// parent::__construct($dsn, SQLITE3_OPEN_READWRITE );
|
|
// $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();
|
|
// return $this->result;
|
|
// }
|
|
|
|
// public function getResults(): array {
|
|
// return $this->result->fetchArray();
|
|
// }
|
|
// }
|