Bonjour j'essaye d'optimiser mon petit bout de code , c'est un script automatique saut qu'il est assez a faire le traitement et je vois pas comment l'optimiser
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 $cx = Connexion::getConnexion(); $query = "SELECT id_community FROM community"; $insert = $cx->prepare($query); $insert->execute(); $result = $insert->fetchAll(); //$community = new Community(); foreach($result as $key){ $json = json_decode(file_get_contents('http://graph.facebook.com/'.$key['id_community'])); // Recupere les likes $likes = $json->{'likes'}; $insert2 = $cx->prepare("INSERT INTO fan(community_id_community, fan_nb, fan_date) VALUES (:community_id, :fan_nb, :fan_date)"); $insert2->bindParam(':community_id', $key['id_community']); $insert2->bindParam(':fan_nb', $likes); $insert2->bindParam(':fan_date',$date); if($insert2->execute()){ } }
Partager