Created
October 20, 2015 19:26
-
-
Save SebSept/1bcb35ed30e2c5d52dc9 to your computer and use it in GitHub Desktop.
Prestashop DbPdo class override | /override/classes/db/DbPDO.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Class DbPDOCore | |
* | |
* /override/classes/db/DbPDO.php | |
* @since 1.5.0.1 | |
*/ | |
class DbPDO extends DbPDOCore | |
{ | |
/** | |
* Tries to connect to the database | |
* | |
* @see DbCore::connect() | |
* @return PDO | |
*/ | |
public function connect() | |
{ | |
try { | |
$this->link = $this->_getPDO($this->server, $this->user, $this->password, $this->database, 5); | |
} catch (PDOException $e) { | |
// modifications | |
file_put_contents(__DIR__.'/../../../log/db_defects.log', date('d/m/Y H:m:s')."\t {$e->getMessage()} \n", FILE_APPEND); | |
header('Erreur Connexion base de donnees', true, 503); | |
echo file_get_contents(__DIR__.'/../../../error500.html'); | |
exit(1); | |
// ligne d'origine, commentée | |
// die(sprintf(Tools::displayError('Link to database cannot be established: %s'), utf8_encode($e->getMessage()))); | |
} | |
// UTF-8 support | |
if ($this->link->exec('SET NAMES \'utf8\'') === false) { | |
die(Tools::displayError('PrestaShop Fatal error: no utf-8 support. Please check your server configuration.')); | |
} | |
return $this->link; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Code utilisé pour mon article sur la personnalisation du message d'echec à la connexion à la base de données Prestashop.