1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
   |  
$updated = 0;
foreach($abonnes as $line) {
	$sth = $dbh->prepare('SELECT pseudo FROM members WHERE LOWER(pseudo) LIKE :name', , array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
	$sth->execute(array(':name' => strtolower(preg_replace('/\s+/', '_', trim($line['name'])))));
	$matches = $sth->fetchAll();
	if(count($matches) == 1) {
		$sth = $dbh->prepare('UPDATE members SET abonneNum = :numAbonne pseudo WHERE pseudo = :pseudo', , array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
		$sth->execute(array(':numAbonne' => $line['numAbonne'], ':pseudo' => $matches[0]['pseudo']);
		$updated++;
	} elseif(count($matches) > 1) {
		echo 'RESULTATS MULTIPLES<br />Num: ', $line['numAbonne'], '<br />Results: ', var_dump($matches), '<br /><br />';
	} else {
		echo 'NO RESULT FOUND FOR ', $line['numAbonne'], '<br /><br />';
	}
}
echo 'Updated ', $updated, ' / ', count($abonnes); | 
Partager