2015-04-02 23:23:34 +02:00
|
|
|
<?php
|
|
|
|
namespace Framadate\Repositories;
|
|
|
|
|
|
|
|
use Framadate\FramaDB;
|
|
|
|
|
|
|
|
abstract class AbstractRepository {
|
|
|
|
/**
|
|
|
|
* @var FramaDB
|
|
|
|
*/
|
|
|
|
private $connect;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* PollRepository constructor.
|
|
|
|
* @param FramaDB $connect
|
|
|
|
*/
|
2021-12-20 17:46:50 +01:00
|
|
|
public function __construct(FramaDB $connect) {
|
2015-04-02 23:23:34 +02:00
|
|
|
$this->connect = $connect;
|
|
|
|
}
|
|
|
|
|
2021-12-20 17:46:50 +01:00
|
|
|
public function beginTransaction(): void
|
|
|
|
{
|
2015-04-02 23:23:34 +02:00
|
|
|
$this->connect->beginTransaction();
|
|
|
|
}
|
|
|
|
|
2021-12-20 17:46:50 +01:00
|
|
|
public function commit(): void
|
|
|
|
{
|
2015-04-02 23:23:34 +02:00
|
|
|
$this->connect->commit();
|
|
|
|
}
|
|
|
|
|
2021-12-20 17:46:50 +01:00
|
|
|
public function rollback(): void
|
|
|
|
{
|
2015-04-03 00:11:36 +02:00
|
|
|
$this->connect->rollback();
|
|
|
|
}
|
|
|
|
|
2021-12-20 17:46:50 +01:00
|
|
|
/**
|
|
|
|
* @return \PDOStatement|false
|
|
|
|
*/
|
|
|
|
public function prepare(string $sql) {
|
2015-04-02 23:23:34 +02:00
|
|
|
return $this->connect->prepare($sql);
|
|
|
|
}
|
|
|
|
|
2021-12-20 17:46:50 +01:00
|
|
|
/**
|
|
|
|
* @return \PDOStatement|false
|
|
|
|
*/
|
|
|
|
public function query($sql) {
|
2015-04-03 00:11:36 +02:00
|
|
|
return $this->connect->query($sql);
|
|
|
|
}
|
|
|
|
|
2021-12-20 17:46:50 +01:00
|
|
|
public function lastInsertId(): string {
|
2015-04-03 00:11:36 +02:00
|
|
|
return $this->connect->lastInsertId();
|
|
|
|
}
|
2015-04-02 23:23:34 +02:00
|
|
|
}
|