Subversion Repositories eFlore/Applications.del

Rev

Rev 1565 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1565 mathias 1
<?php
2
 
3
/**
4
 * Script de mise à jour de la table "del_image_stat"
5
 * @author mathias
6
 */
7
class Stats extends DelScript {
8
 
9
	public function executer() {
10
		$this->majStats();
11
	}
12
 
13
	/**
14
	 * Met à jour la table des statistiques en la vidant et en recalculant la moyenne pondérée,
15
	 * le nombre de votes et le nombre de points pour chaque image - utilise "commun".
16
	 * Attention, c'est over-pas-optimisé, ça prend du temps !
17
	 */
18
	protected function majStats() {
19
		$requete = "SELECT id_image FROM del_image ORDER BY id_image ASC";
20
		$ids = $this->getBdd()->recupererTous($requete);
21
 
22
		$requete = "SELECT id_protocole FROM del_image_protocole ORDER BY id_protocole ASC";
23
		$protos = $this->getBdd()->recupererTous($requete);
24
 
25
		foreach ($ids as $id) {
26
			echo "ID: " . $id['id_image'] . "\n";
27
			foreach ($protos as $proto) {
28
				TelaBotanica\Del\Commun\Stats::updateStats($this->getBdd(), $id['id_image'], $proto['id_protocole']);
29
			}
30
		}
31
	}
32
}