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
| try
{
$ptPDO =new PDO('mysql:host='.$this->host.';dbname='.$this->nomBDD, $this->login, $this->mdp,array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
echo '<br/>PDO:'.$sql.'<br/>';
if(startswith($sql,'CREATE'))
{
echo '<br/>CREATE<br/>';
$ptPDO->exec($sql);
if($prep === FALSE)
echo 'Probleme PDO : ' . $prep->errorInfo();
else
echo 'Table creee';
}
else
{
$prep = $ptPDO->prepare($sql);
if(sizeof($_tWhere)>0)
{
$prep->execute($_tWhere);
}
else
$prep->execute();
if(startswith($sql, 'SELECT'))
{
$result = $prep->fetchAll();
self::traitementRes($result);
}
}
}
catch (PDOException $e)
{
echo 'Probleme PDO : ' . $e->getMessage();
echo 'N : '.$e->getCode();
echo 'N : '.$e->getLine();
die();
} |