Skip to content
Snippets Groups Projects
Commit 03e3c637 authored by Laurent's avatar Laurent
Browse files

hotline #17328 sql_server_gone_away

increase session wait_timeout
parent 0bd07a26
5 merge requests!529Hotline 6.56,!512Master,!511Master,!510Hotline 6.55,!502Hotline#17328 sql server gone away
......@@ -16,7 +16,7 @@
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with AFI-OPAC 2.0; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/////////////////////////////////////////////////////////////////////////////////////////////////
// SQL qui s'appuie sur PDO
......@@ -33,17 +33,22 @@ class sql
// ---------------------------------------------------
// Constructeur : connexion à la base
// ---------------------------------------------------
// ---------------------------------------------------
function __construct($server,$user,$pwd,$base)
{
$dns="mysql:dbname=".$base.";host=".$server;
try { $this->hpdo=new PDO($dns,$user,$pwd); }
catch (PDOException $e) { afficherErreur('<b><font color="red">Impossible de se connecter au moteur Mysql</font></b><br>'.$e->getMessage());}
try {
$this->hpdo=new PDO($dns,$user,$pwd); }
catch (PDOException $e) {
afficherErreur('<b><font color="red">Impossible de se connecter au moteur Mysql</font></b><br>'.$e->getMessage());
}
$this->hpdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$query = $this->hpdo->prepare("set session wait_timeout=10000");
$query->execute();
}
// ---------------------------------------------------
// Resultat pour 1 seule colonne et 1 seul enreg
// ---------------------------------------------------
// ---------------------------------------------------
public function fetchOne($req)
{
try
......@@ -102,8 +107,8 @@ class sql
// ---------------------------------------------------
public function execute($req)
{
try
{
try
{
$nombre=$this->hpdo->exec($req);
return $nombre;
}
......@@ -142,7 +147,7 @@ class sql
public function insert($table,$data) {
$cols = implode(',', array_keys($data));
$statement = isset($this->statements[$table][$cols])
? $this->statements[$table][$cols]
? $this->statements[$table][$cols]
: $this->statements[$table][$cols] = $this->createInsertPrepareStatement($table, $data);
foreach($data as $col => $valeur)
......@@ -163,7 +168,7 @@ class sql
$placeholders = array();
foreach($cols as $col)
$placeholders []= ':'.$col;
return $this->hpdo->prepare('insert into '.$table.' ('.implode(',', $cols).') VALUES ('.implode(',', $placeholders).')');
return $this->hpdo->prepare('insert into '.$table.' ('.implode(',', $cols).') VALUES ('.implode(',', $placeholders).')');
}
// ---------------------------------------------------
......@@ -206,7 +211,7 @@ class sql
// ---------------------------------------------------
public function ignoreErreurs($mode)
{
$this->ignore_erreurs=$mode;
$this->ignore_erreurs=$mode;
}
// ---------------------------------------------------
// Traitement des erreurs
......@@ -235,10 +240,10 @@ class sql
$msg.=" - <b>Fonction : </b>". $lig["function"].BR;
}
$msg.='</div>';
// Afficher l'erreur
if( getVariable("sql_debug") == 1) print('</center>'.$msg);
// On log l'erreur
if(!$this->log) $this->log=new Class_log("sql",false);
$this->log->open(true);
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment