![Olivier PEREZ](/assets/img/avatar_default.png)
* Store all informations about forms into an object "Form" stored in $_SESSION['form'] * Replace connection to database by PDO object * Check if database is ready in bandeaux.php file
40 lines
823 B
PHP
40 lines
823 B
PHP
<?php
|
|
namespace Framadate;
|
|
|
|
class FramaDB
|
|
{
|
|
/**
|
|
* PDO Object, connection to database.
|
|
*/
|
|
private $pdo = null;
|
|
|
|
function __construct($connection_string, $user, $password)
|
|
{
|
|
$this->pdo = new \PDO($connection_string, $user, $password);
|
|
}
|
|
|
|
function areTablesCreated()
|
|
{
|
|
$result= $this->pdo->query('SHOW TABLES');
|
|
$schemas = $result->fetchAll(\PDO::FETCH_COLUMN);
|
|
return !empty(array_diff($schemas, ['comments', 'sondage', 'sujet_studs', 'user_studs']));
|
|
}
|
|
|
|
function prepare($sql) {
|
|
return $this->pdo->prepare($sql);
|
|
}
|
|
|
|
function beginTransaction() {
|
|
$this->pdo->beginTransaction();
|
|
}
|
|
|
|
function commit() {
|
|
$this->pdo->commit();
|
|
}
|
|
|
|
function query($sql) {
|
|
return $this->pdo->query($sql);
|
|
}
|
|
|
|
}
|