Subversion Repositories eFlore/Applications.del

Rev

Rev 1490 | Rev 1666 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1490 Rev 1584
Line 223... Line 223...
223
						array('id_protocole', 'intitule', 'descriptif', 'tag' /* del_image_protocole */ ));
223
						array('id_protocole', 'intitule', 'descriptif', 'tag' /* del_image_protocole */ ));
224
		$vote_fields = DelTk::sqlFieldsToAlias(self::$mappings['votes'], $select['votes'], 'v'); // "v": cf alias dans la requête
224
		$vote_fields = DelTk::sqlFieldsToAlias(self::$mappings['votes'], $select['votes'], 'v'); // "v": cf alias dans la requête
225
		$proto_fields = DelTk::sqlFieldsToAlias(self::$mappings['protocoles'], $select['protocole'], 'p');
225
		$proto_fields = DelTk::sqlFieldsToAlias(self::$mappings['protocoles'], $select['protocole'], 'p');
Line 226... Line 226...
226
		
226
		
-
 
227
		$where = array();
227
		$where = array();
228
		$idsImages = array_values(array_map(create_function('$a', 'return $a["id_image"];'), $images));
228
		$where[] = sprintf('v.ce_image IN (%s)',
229
		$where[] = sprintf('v.ce_image IN (%s)',
Line 229... Line 230...
229
						   implode(',', array_values(array_map(create_function('$a', 'return $a["id_image"];'), $images))));
230
						   implode(',', $idsImages));
230
 
231
 
231
		if ($protocole) {
232
		if ($protocole) {
Line -... Line 233...
-
 
233
			$where[] = "v.ce_protocole = $protocole";
-
 
234
		}
232
			$where[] = "v.ce_protocole = $protocole";
235
 
233
		}
236
		// pour une fois, on conserve l'ordre en ne luttant pas contre les IDs reçus
234
 
237
		$ordreDesIdsRecus = sprintf('FIELD(v.ce_image, %s)', implode(',', $idsImages));
-
 
238
		$req = sprintf(
235
		return $db->recupererTous(sprintf(
239
			'SELECT %s, %s FROM del_image_vote AS v'.
-
 
240
			' INNER JOIN del_image_protocole p ON v.ce_protocole = p.id_protocole'.
236
			'SELECT %s, %s FROM del_image_vote AS v'.
241
			' WHERE %s'.
237
			' INNER JOIN del_image_protocole p ON v.ce_protocole = p.id_protocole'.
242
			' ORDER BY %s -- %s',
-
 
243
			$vote_fields,
238
			' WHERE %s -- %s',
244
			$proto_fields,
-
 
245
			($where ? implode(' AND ', $where) : 1),
-
 
246
			$ordreDesIdsRecus,
-
 
247
			__FILE__ . ':' . __LINE__);
-
 
248
		
239
			$vote_fields, $proto_fields,
249
		//echo "REQUETE: $req"; exit;
Line 240... Line 250...
240
			$where ? implode(' AND ', $where) : 1,
250
 
241
			__FILE__ . ':' . __LINE__));
251
		return $db->recupererTous($req);
242
	}
252
	}