function SELECTquery($select_fields, $from_table, $where_clause, $groupBy = '', $orderBy = '', $limit = '')
{
// Table and fieldnames should be "SQL-injection-safe" when supplied to this function
// Build basic query:
$query = 'SELECT ' . $select_fields . '
FROM ' . $from_table . (strlen($where_clause) > 0 ? '
WHERE
' . $where_clause : '');
// Group by:
if (strlen($groupBy) > 0) {
$query .= '
GROUP BY ' . $groupBy;
}
// Order by:
if (strlen($orderBy) > 0) {
$query .= '
ORDER BY ' . $orderBy;
}
// Group by:
if (strlen($limit) > 0) {
$query .= '
LIMIT ' . $limit;
}
// Return query:
if ($this->debugOutput || $this->store_lastBuiltQuery) {
$this->debug_lastBuiltQuery = $query;
}
return $query;
}