From 8e9c2625f2ea74f577f45418e0c95ff298e2ddcf Mon Sep 17 00:00:00 2001 From: Scott Date: Sat, 12 Jan 2019 18:25:52 +0000 Subject: [PATCH] Fix MySQL reserved keyword clash Fixes #725 --- qa-include/qa-db.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/qa-include/qa-db.php b/qa-include/qa-db.php index b2e70570c..d32576123 100644 --- a/qa-include/qa-db.php +++ b/qa-include/qa-db.php @@ -548,8 +548,9 @@ function qa_db_single_select($selectspec) $query = 'SELECT '; - foreach ($selectspec['columns'] as $columnas => $columnfrom) - $query .= $columnfrom . (is_int($columnas) ? '' : (' AS ' . $columnas)) . ', '; + foreach ($selectspec['columns'] as $columnas => $columnfrom) { + $query .= is_int($columnas) ? "$columnfrom, " : "$columnfrom AS `$columnas`, "; + } $results = qa_db_read_all_assoc(qa_db_query_raw(qa_db_apply_sub( substr($query, 0, -2) . (strlen(@$selectspec['source']) ? (' FROM ' . $selectspec['source']) : ''),