2015-04-02 23:23:34 +02:00
|
|
|
<?php
|
|
|
|
namespace Framadate\Repositories;
|
|
|
|
|
2018-04-18 16:16:22 +02:00
|
|
|
use Doctrine\DBAL\Connection;
|
2015-04-02 23:23:34 +02:00
|
|
|
|
|
|
|
abstract class AbstractRepository {
|
|
|
|
/**
|
2018-04-18 16:16:22 +02:00
|
|
|
* @var Connection
|
2015-04-02 23:23:34 +02:00
|
|
|
*/
|
2018-04-18 16:16:22 +02:00
|
|
|
protected $connect;
|
2015-04-02 23:23:34 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* PollRepository constructor.
|
2018-04-18 16:16:22 +02:00
|
|
|
* @param Connection $connect
|
2015-04-02 23:23:34 +02:00
|
|
|
*/
|
2018-04-18 16:16:22 +02:00
|
|
|
public function __construct(Connection $connect) {
|
2015-04-02 23:23:34 +02:00
|
|
|
$this->connect = $connect;
|
2018-04-18 16:16:22 +02:00
|
|
|
$this->connect->setFetchMode(\PDO::FETCH_OBJ);
|
2015-04-02 23:23:34 +02:00
|
|
|
}
|
|
|
|
|
2018-04-18 16:16:22 +02:00
|
|
|
public function beginTransaction()
|
|
|
|
{
|
2015-04-02 23:23:34 +02:00
|
|
|
$this->connect->beginTransaction();
|
|
|
|
}
|
|
|
|
|
2018-04-18 16:16:22 +02:00
|
|
|
/**
|
|
|
|
* @throws \Doctrine\DBAL\ConnectionException
|
|
|
|
*/
|
|
|
|
public function commit()
|
|
|
|
{
|
2015-04-02 23:23:34 +02:00
|
|
|
$this->connect->commit();
|
|
|
|
}
|
|
|
|
|
2018-04-18 16:16:22 +02:00
|
|
|
/**
|
|
|
|
* @throws \Doctrine\DBAL\ConnectionException
|
|
|
|
*/
|
|
|
|
public function rollback()
|
|
|
|
{
|
2015-04-03 00:11:36 +02:00
|
|
|
$this->connect->rollback();
|
|
|
|
}
|
|
|
|
|
2018-04-18 16:16:22 +02:00
|
|
|
/**
|
|
|
|
* @param string $sql
|
|
|
|
* @throws \Doctrine\DBAL\DBALException
|
|
|
|
* @return bool|\Doctrine\DBAL\Driver\Statement|\PDOStatement
|
|
|
|
*/
|
|
|
|
public function prepare($sql)
|
|
|
|
{
|
2015-04-02 23:23:34 +02:00
|
|
|
return $this->connect->prepare($sql);
|
|
|
|
}
|
|
|
|
|
2018-04-18 16:16:22 +02:00
|
|
|
/**
|
|
|
|
* @param string $sql
|
|
|
|
* @throws \Doctrine\DBAL\DBALException
|
|
|
|
* @return bool|\Doctrine\DBAL\Driver\Statement|\PDOStatement
|
|
|
|
*/
|
|
|
|
public function query($sql)
|
|
|
|
{
|
2015-04-03 00:11:36 +02:00
|
|
|
return $this->connect->query($sql);
|
|
|
|
}
|
|
|
|
|
2018-04-18 16:16:22 +02:00
|
|
|
/**
|
|
|
|
* @return string
|
|
|
|
*/
|
|
|
|
public function lastInsertId()
|
|
|
|
{
|
2015-04-03 00:11:36 +02:00
|
|
|
return $this->connect->lastInsertId();
|
|
|
|
}
|
2015-04-02 23:23:34 +02:00
|
|
|
}
|