@@ 371-391 (lines=21) @@ | ||
368 | * @param {Array} un tableau de tous les filtres éventuels |
|
369 | * @param {string} le champ sur lequel ordonner |
|
370 | **/ |
|
371 | public static function findAllAttributeFromTable($table, $attribute, $where = array(), $options = array()) |
|
372 | { |
|
373 | $SQL = "SELECT id\n"; |
|
374 | if ($attribute != 'id') { |
|
375 | $SQL .= "," . $attribute . "\n"; |
|
376 | } |
|
377 | $SQL .= "FROM $table "; |
|
378 | $SQL .= Sql::parseWhere($where); |
|
379 | ||
380 | if (isset($options["order"]) && $options["order"]) { |
|
381 | $SQL .= " ORDER BY " . $options["order"]; |
|
382 | } |
|
383 | if (isset($options["limit"]) && $options["limit"]) { |
|
384 | $SQL .= " LIMIT " . $options["limit"]; |
|
385 | } |
|
386 | //echo($SQL); |
|
387 | // Exécution de la requète |
|
388 | $db = \Model::getDb(); |
|
389 | $result = $db->fetchAll($SQL); |
|
390 | return $result; |
|
391 | } |
|
392 | ||
393 | public static function findAllAttributeFromLeftJoinTable( |
|
394 | $table, |
|
@@ 393-417 (lines=25) @@ | ||
390 | return $result; |
|
391 | } |
|
392 | ||
393 | public static function findAllAttributeFromLeftJoinTable( |
|
394 | $table, |
|
395 | $left_table, |
|
396 | $link_table, |
|
397 | $attribute, |
|
398 | $where = array(), |
|
399 | $options = array() |
|
400 | ) |
|
401 | { |
|
402 | $SQL = "SELECT $attribute \n"; |
|
403 | $SQL .= " FROM $table \n LEFT JOIN $left_table \n"; |
|
404 | $SQL .= " ON $link_table \n"; |
|
405 | $SQL .= Sql::parseWhere($where); |
|
406 | ||
407 | if (isset($options["order"]) && $options["order"]) { |
|
408 | $SQL .= " ORDER BY " . $options["order"] . " \n"; |
|
409 | } |
|
410 | if (isset($options["limit"]) && $options["limit"]) { |
|
411 | $SQL .= " LIMIT " . $options["limit"]; |
|
412 | } |
|
413 | //debug::output($SQL); |
|
414 | // Exécution de la requète |
|
415 | $db = \Model::getDb(); |
|
416 | $result = $db->getIterator($SQL); |
|
417 | return $result; |
|
418 | } |
|
419 | ||
420 | /** |