8d6a2feb |
<?php
|
daf6e125 |
namespace MVC\Classe;
|
8d6a2feb |
class Bdd
{
public $bdd;
|
6602a9e3 |
public function __construct($bdd = 'bdd1')
|
8d6a2feb |
{
|
3957c7ee |
switch($bdd) {
|
6602a9e3 |
case 'bdd1':
$this->bdd = new PDO(DSN_BDD1, USER_BDD1, PASS_BDD1);
|
af2e49d1 |
break;
|
6602a9e3 |
case 'bdd2':
$this->bdd = new PDO(DSN_BDD2, USER_BDD2, PASS_BDD2);
|
af2e49d1 |
break;
|
3957c7ee |
default:
|
af2e49d1 |
$this->bdd = new PDO(DSN_BDD_DEFAULT, USER_BDD_DEFAULT, PASS_BDD_DEFAULT);
|
3957c7ee |
}
|
8d6a2feb |
}
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){
|
af2e49d1 |
if (is_string($row)) {
$row = Caracter::normalise_ChaineDeCaracteresDownload($row);
}
|
8d6a2feb |
$tab[$key] = $row;
}
return $tab;
}
}
|