1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
| <?php
/*****************************
* Class MySQL *
* *
* Author: *
* DIEUNIDOU Sébastien *
*****************************/
class MySqL
{
private $Host;
private $User;
private $Pass;
private $Base;
private $Mysql;
private $debuging;
static $query;
public $Count_Query = 0;
function __construct($host, $user, $pass, $base)
{
$this->Host = $host;
$this->User = $user;
$this->Pass = $pass;
$this->Base = $base;
$this->debuging = new Debuger();
$this->debuging->debug = TRUE;
}
public function MConnect()
{
if(!$this->Mysql = mysql_connect($this->Host, $this->User, $this->Pass))
$this->debuging->debug('MYSQL', 'Connexion à MYSQL impossible', __LINE__, __FILE__);
}
public function DBSelect()
{
if(!mysql_select_db($this->Base, $this->Mysql))
$this->debuging->debug('MYSQL', 'Impossible de sélectionner la base de données', __LINE__, __FILE__);
}
public function MClose()
{
mysql_close($this->Mysql);
}
public function Query($query)
{
if(!$this->query = @mysql_query($query))
$this->debuging->debug('MYSQL', 'Requête invalide', __LINE__, __FILE__);
else
{
$this->Count_Query++;
return $this->query;
}
}
}
$MySqL = new MySqL('localhost', 'root', 'pass', 'test');
$MySqL->MConnect();
$MySqL->DBSelect();
$query = $MySqL->Query('SELECT * FROM `dossiers`');
while($row = mysql_fetch_object($query))
{
echo '<p><strong>Auteur: </strong>' . $row->auteur . '</p>';
}
?> |
Partager