Fixed issue #102
This commit is contained in:
parent
ff1a2a5f8a
commit
c455299b5d
@ -127,6 +127,24 @@ class mypdo extends Database
|
|||||||
try {
|
try {
|
||||||
$this->db_connect = new PDO("$this->dbtype:host=$this->server;port=$this->dbport;dbname=$this->dbname;charset=$this->dbcharset", "$this->user", "$this->password"); // PDO Connection
|
$this->db_connect = new PDO("$this->dbtype:host=$this->server;port=$this->dbport;dbname=$this->dbname;charset=$this->dbcharset", "$this->user", "$this->password"); // PDO Connection
|
||||||
} catch (PDOException $e) {
|
} catch (PDOException $e) {
|
||||||
|
// var_dump($e);
|
||||||
|
// echo $e->getCode();
|
||||||
|
// echo $e->getMessage();
|
||||||
|
switch($e->getCode()) {
|
||||||
|
case 2002:
|
||||||
|
echo
|
||||||
|
"<tr>
|
||||||
|
<th align='left' bgcolor='#f57900' colspan='5'><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> Connexion à la base de données impossible !</th></tr>";
|
||||||
|
die();
|
||||||
|
// break;
|
||||||
|
case 1045:
|
||||||
|
case 1044:
|
||||||
|
echo
|
||||||
|
"<tr>
|
||||||
|
<th align='left' bgcolor='#f57900' colspan='5'><span style='background-color: #cc0000; color: #fce94f; font-size: x-large;'>( ! )</span> ".$e->getMessage()."</th> </tr>";
|
||||||
|
die();
|
||||||
|
// break;
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -182,11 +200,15 @@ class mypdo extends Database
|
|||||||
if($query != "")
|
if($query != "")
|
||||||
{
|
{
|
||||||
$this->num_queries++;
|
$this->num_queries++;
|
||||||
$this->query_result = $this->db_connect->prepare($query);
|
|
||||||
if( !$data )
|
$this->query_result = $this->db_connect->prepare($query);
|
||||||
|
|
||||||
|
if( !$data )
|
||||||
$this->query_result->execute();
|
$this->query_result->execute();
|
||||||
else
|
else
|
||||||
$this->query_result->execute($data);
|
$this->query_result->execute($data);
|
||||||
|
} else {
|
||||||
|
$this->sql_error();
|
||||||
}
|
}
|
||||||
if(isset($this->query_result))
|
if(isset($this->query_result))
|
||||||
{
|
{
|
||||||
@ -477,8 +499,9 @@ class mypdo extends Database
|
|||||||
*/
|
*/
|
||||||
function sql_error($query_id = 0)
|
function sql_error($query_id = 0)
|
||||||
{
|
{
|
||||||
$result["message"] = @mysql_error($this->db_connect);
|
// $result["message"] = @mysql_error($this->db_connect);
|
||||||
$result["code"] = @mysql_errno($this->db_connect);
|
// $result["code"] = @mysql_errno($this->db_connect);
|
||||||
|
$result = $this->db_connect->errorInfo();
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user