Test de mise en place de bd SQlite3
continuous-integration/drone/push Build is passing Details

ServeurDeTest
Noé Garnier 2 years ago
parent a1328387e8
commit a7ee19e947

@ -14,7 +14,7 @@ $rep = __DIR__ . '/../';
// $password = 'p';
// SQULITE3
// $dsn = 'sqlite:./Model/scripted.db';
$dsn = 'sqlite:./Model/scripted.db';
// $user = null;
// $password = null;

@ -19,8 +19,23 @@
class Connection extends SQLite3
{
function __construct()
private $stmt;
private $result;
function __construct($dsn)
{
$this->open('./Model/scripted.db');
$this->open($dsn);
}
public function executeQuery(string $query, array $parameters = []) :bool {
$this->stmt = $this->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();
}
}

@ -6,7 +6,6 @@ class FrontController
session_start();
// $role=$_SESSION['role'];
// $action=$_REQUEST['action'];
echo "front";
new UserController();
}
}

@ -2,26 +2,17 @@
class UserController
{
// function __construct(){
// $
// }
private Connection $con;
function __construct() {
global $dsn, $user, $password;
// $this->con=new Connection($dsn);
$this->con=new Connection ();
global $dsn;
$this->con=new Connection ($dsn);
try{
global $rep, $vues, $error;
$action=$_REQUEST['action'];
echo "userController";
switch($action) {
case NULL:
$db= new Connection();
$db->exec('INSERT INTO Utilisateur VALUES ("e","e","e", false)' );
$res=$db->exec('SELECT * FROM Utilisateur' );
echo $res;
// require ($rep.$vues['main']);
$this->goToHome();
break;
case "signUp":
$this->signUp();

@ -3,23 +3,21 @@ require_once('./Config/Config.php');
require_once('./Config/Autoload.php');
Autoload::charger();
$db = new Connection();
//Insert a new user in the database
// $db->exec('INSERT INTO Utilisateur VALUES ("e","e","e", false)');
$stm=$db->prepare("INSERT INTO Utilisateur VALUES (:email, :password, :pseudo, :admin)");
$stm->bindValue(':email', "e",SQLITE3_TEXT);
$stm->bindValue(':password', "e" ,SQLITE3_TEXT);
$stm->bindValue(':pseudo', "e", SQLITE3_TEXT);
$stm->bindValue(':admin', 0, SQLITE3_INTEGER);
$stm->execute();
// $db = new Connection();
// $stm=$db->prepare("INSERT INTO Utilisateur VALUES (:email, :password, :pseudo, :admin)");
// $stm->bindValue(':email', "e",SQLITE3_TEXT);
// $stm->bindValue(':password', "e" ,SQLITE3_TEXT);
// $stm->bindValue(':pseudo', "e", SQLITE3_TEXT);
// $stm->bindValue(':admin', 0, SQLITE3_INTEGER);
// $stm->execute();
$res = $db->query('SELECT * FROM Utilisateur');
// Select all the users in the database
while ($row = $res->fetchArray()) {
echo $row['email'] . " " . $row['password'] . " " . $row['pseudo'] . " " . $row['admin'] . " ";
}
// $res = $db->query('SELECT * FROM Utilisateur');
// // Select all the users in the database
// while ($row = $res->fetchArray()) {
// echo $row['email'] . " " . $row['password'] . " " . $row['pseudo'] . " " . $row['admin'] . " ";
// }
// $control = new FrontController();
$control = new FrontController();
//session_regenerate_id(true);

Loading…
Cancel
Save