SAND-framework/application/class/bdd.class.php

35 lines
782 B
PHP
Raw Normal View History

2019-03-05 16:49:15 +01:00
<?php
class Bdd
{
public $bdd;
public function __construct($bdd = 'fiches3')
2019-03-05 16:49:15 +01:00
{
switch($bdd) {
case 'fiches3':
$this->bdd = new PDO(DSN_FICHES, USER_FICHES, PASS_FICHES);
break;
case 'abitop':
$this->bdd = new PDO(DSN_ABITOP, USER_ABITOP, PASS_ABITOP);
break;
default:
$this->bdd = new PDO(DSN_FICHES, USER_FICHES, PASS_FICHES);
}
2019-03-05 16:49:15 +01:00
}
public function faireUneRequete($sql)
{
$req = $this->bdd->query($sql, PDO::FETCH_ASSOC);
return $req;
}
public function creerTableau($res){
$tab = array();
foreach($res as $key => $row){
$tab[$key] = $row;
}
return $tab;
}
}