Skip to content

Instantly share code, notes, and snippets.

@SebSept
Created October 20, 2015 19:26
Show Gist options
  • Save SebSept/1bcb35ed30e2c5d52dc9 to your computer and use it in GitHub Desktop.
Save SebSept/1bcb35ed30e2c5d52dc9 to your computer and use it in GitHub Desktop.
Prestashop DbPdo class override | /override/classes/db/DbPDO.php
<?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;
}
}
@SebSept
Copy link
Author

SebSept commented Nov 2, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment