Bonjour,
En remplaçant le paramètre envoyé à la fonction ci-dessous par sa valeur 'FR', phpMyAdmin renvoie une valeur 'EUR'.
Par contre, lorsque j'utilise la fonction avec le même paramètre 'FR' la ligne renvoie true au lieu de la valeur attendue ('EUR'). J'ai beau chercher, je ne comprends pas pourquoi.
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
function getDefaultCurrency($countryId) {
	$db = dbConnect();
	var_dump($countryId);	// 'FR'
	var_dump($db);		// 'object(PDO)[1]'
 
	$sql = "
		SELECT currency_code
		FROM lst_countries
		WHERE id=:countryId
		LIMIT 1
	";
	$stmt = $db->prepare($sql);
	$stmt->bindParam(':countryId', $countryId);
	$stmt->execute();
	var_dump($stmt->fetch()['currency_code'] or die($stmt->errorInfo()));	// true
	echo $stmt->fetch()['currency_code'];
	return $stmt->fetch()['currency_code'];
}
 
 
		$defaultCountry = getDefaultCountry(); // FR
		$defaultCurrency= getDefaultCurrency($defaultCountry);
		var_dump($defaultCurrency);exit;	// null