Subversion Repositories eFlore/Applications.cel

Rev

Rev 2468 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2468 Rev 2480
Line 47... Line 47...
47
		foreach ($ids_images_filtrees as $id_img) {
47
		foreach ($ids_images_filtrees as $id_img) {
48
			foreach ($infos_observations_filtrees as $infos_obs) {
48
			foreach ($infos_observations_filtrees as $infos_obs) {
49
				$id_obs = $infos_obs['id_observation'];
49
				$id_obs = $infos_obs['id_observation'];
50
				$dateTransmission = ($infos_obs['date_transmission'] != '') ? Cel::db()->proteger($infos_obs['date_transmission']) : 'NULL' ;
50
				$dateTransmission = ($infos_obs['date_transmission'] != '') ? Cel::db()->proteger($infos_obs['date_transmission']) : 'NULL' ;
51
				$transmission = $infos_obs['transmission'];
51
				$transmission = $infos_obs['transmission'];
52
				$values[] = "($id_img, $id_obs, NOW(), $dateTransmission, $transmission)";
52
				$values[] = "($id_img, $id_obs, NOW(), NOW(), $dateTransmission, $transmission)";
53
			}
53
			}
54
		}
54
		}
55
		$clauseValues = implode(',', $values);
55
		$clauseValues = implode(',', $values);
-
 
56
		// ceci n'est pas un INSERT, c'est un UPDATE multiple en une seule requête
56
		$requete = 'INSERT INTO cel_images (id_image, ce_observation, date_liaison, date_transmission, transmission) '.
57
		$requete = 'INSERT INTO cel_images (id_image, ce_observation, date_modification, date_liaison, date_transmission, transmission) '.
57
			"VALUES $clauseValues ".
58
			"VALUES $clauseValues ".
58
			'ON DUPLICATE KEY UPDATE '.
59
			'ON DUPLICATE KEY UPDATE '.
59
			'	ce_observation = VALUES(ce_observation), '.
60
			'	ce_observation = VALUES(ce_observation), '.
-
 
61
			'	date_modification = NOW(), '.
60
			'	date_liaison = NOW(), '.
62
			'	date_liaison = NOW(), '.
61
			'	date_transmission = VALUES(date_transmission), '.
63
			'	date_transmission = VALUES(date_transmission), '.
62
			'	transmission = VALUES(transmission) '.
64
			'	transmission = VALUES(transmission) '.
63
			' -- ' . __FILE__ . ':' . __LINE__;
65
			' -- ' . __FILE__ . ':' . __LINE__;
64
		$resultat = Cel::db()->executer($requete);
66
		$resultat = Cel::db()->executer($requete);
65
		if ($resultat) {
67
		if ($resultat) {
-
 
68
			// mise à jour de la date de modification de l'observation
-
 
69
			$idsObsConcat = implode(', ', $ids_observations);
-
 
70
			$requete = "UPDATE cel_obs SET date_modification = NOW() ".
-
 
71
				"WHERE id_observation IN ($idsObsConcat) ".
-
 
72
				' -- ' . __FILE__ . ':' . __LINE__;
-
 
73
			$resultat = Cel::db()->executer($requete);
-
 
74
			// @TODO faudrait faire une transaction et retourner false si l'UPDATE de cel_obs échoue
66
			exit('OK');
75
			exit('OK');
67
		}
76
		}
68
		exit(); // peut-être qu'aucune mise à jour n'a eu lieu (ON DUPLICATE KEY)
77
		exit(); // peut-être qu'aucune mise à jour n'a eu lieu (ON DUPLICATE KEY)
69
	}
78
	}