From 0fb7c76b5c0f4ac77c7fe076e87e7f804124fec2 Mon Sep 17 00:00:00 2001
From: "Committo,Ergo:sum" <esj@rezo.net>
Date: Tue, 22 Sep 2009 16:21:01 +0000
Subject: [PATCH] =?UTF-8?q?Erreurs=20SQL=20en=20multi-serveurs,=20suite:?=
 =?UTF-8?q?=20[14492]=20corrigeait=20dans=20la=20branche=20dev=20pendant?=
 =?UTF-8?q?=20que=20[14484]=20et=20[14489]=20corrigeaient=20dans=20la=20br?=
 =?UTF-8?q?anche=20stable.=20Avec=20=C3=A7a,=20la=20stable=20est=20bien=20?=
 =?UTF-8?q?corrig=C3=A9e=20pour=20MySQL=20et=20PG,=20mais=20dans=20la=20de?=
 =?UTF-8?q?v=20il=20y=20a=20de=20toutes=20fa=C3=A7ons=20le=20chantier=20en?=
 =?UTF-8?q?=20cours=20de=20l'abstraction=20des=20erreurs=20SQL,=20c'est=20?=
 =?UTF-8?q?encore=20incomplet.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 ecrire/req/mysql.php | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/ecrire/req/mysql.php b/ecrire/req/mysql.php
index 6f16c741e7..30a51cfd23 100644
--- a/ecrire/req/mysql.php
+++ b/ecrire/req/mysql.php
@@ -506,7 +506,8 @@ function spip_mysql_countsel($from = array(), $where = array(),
 
 // http://doc.spip.org/@spip_mysql_error
 function spip_mysql_error($query='', $serveur='',$requeter=true) {
-	$s = mysql_error();
+	$link = $GLOBALS['connexions'][$serveur ? $serveur : 0]['link'];
+	$s = $link ? mysql_error($link) : mysql_error();
 	if ($s) spip_log("$s - $query", 'mysql');
 	return $s;
 }
@@ -514,7 +515,8 @@ function spip_mysql_error($query='', $serveur='',$requeter=true) {
 // A transposer dans les portages
 // http://doc.spip.org/@spip_mysql_errno
 function spip_mysql_errno($serveur='',$requeter=true) {
-	$s = mysql_errno();
+	$link = $GLOBALS['connexions'][$serveur ? $serveur : 0]['link'];
+	$s = $link ? mysql_errno($link) : mysql_errno();
 	// 2006 MySQL server has gone away
 	// 2013 Lost connection to MySQL server during query
 	if (in_array($s, array(2006,2013)))
-- 
GitLab