diff --git a/cosmogramme/php/classes/classe_sql.php b/cosmogramme/php/classes/classe_sql.php index edc9fb786ad6e465c1edb2d3ed947e67a8b0ba68..58c181186f9c1ac1b30abdd9ad5fe72e3b8e532b 100644 --- a/cosmogramme/php/classes/classe_sql.php +++ b/cosmogramme/php/classes/classe_sql.php @@ -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);