Bonjour,

j'ai la requête suivante que j'aimerais transformer en requête PDO :

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
 
$sqla = sprintf("SELECT cont_".$lang." FROM flatforswap_continent ORDER BY cont_".$lang." ASC");
 
 
 
				$reqa = mysql_query($sqla) or die('Erreur SQL !<br>'.$sqla.'<br>'.mysql_error());
				while($dataa = mysql_fetch_assoc($reqa))
				{
					if ($continent == $dataa['cont_'.$lang.''])
					{
						echo '<option value="'.$dataa['cont_'.$lang.''].'" selected="selected">'.$dataa['cont_'.$lang.''].'</option>';
					}
					if ($continent != $dataa['cont_'.$lang.''])
					{
						echo '<option value="'.$dataa['cont_'.$lang.''].'">'.$dataa['cont_'.$lang.''].'</option>';
					}
				}
La requête suivante (version PDO), est-elle suivante :

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
 
	$sqla = $db->prepare("SELECT cont_".$lang." FROM flatforswap_continent ORDER BY cont_".$lang." ASC");
 
 
 
				$sqla->execute(array());
				while($dataa = mysql_fetch_assoc($sqla))
				{
					if ($continent == $dataa['cont_'.$lang.''])
					{
						echo '<option value="'.$dataa['cont_'.$lang.''].'" selected="selected">'.$dataa['cont_'.$lang.''].'</option>';
					}
					if ($continent != $dataa['cont_'.$lang.''])
					{
						echo '<option value="'.$dataa['cont_'.$lang.''].'">'.$dataa['cont_'.$lang.''].'</option>';
					}
				}
Merci d'avance pour votre aide.