mirror of
https://github.com/RaspbianFrance/raspisms.git
synced 2025-04-20 16:37:48 +02:00
add aliases for query fields
This commit is contained in:
parent
e3a2dc29df
commit
eec309bf61
1 changed files with 6 additions and 1 deletions
|
@ -388,7 +388,12 @@
|
|||
$i++;
|
||||
}
|
||||
|
||||
$query = "SELECT * FROM " . $table . $join . " WHERE 1 " . (count($wheres) ? 'AND ' : '') . implode('AND ', $wheres);
|
||||
// liste les champs disponibles pour ajouter des alias et éviter des problèmes en cas de colonnes avec le même nom
|
||||
$fieldNames = array_keys($fields);
|
||||
foreach ($fieldNames as $key => $fieldName) {
|
||||
$fieldNames[$key] = $fieldName . " AS '" . $fieldName . "'";
|
||||
}
|
||||
$query = "SELECT " . implode(', ', $fieldNames) . " FROM " . $table . $join . " WHERE 1 " . (count($wheres) ? 'AND ' : '') . implode('AND ', $wheres);
|
||||
|
||||
if ($order_by)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue