SQL select issue with '_'

SQL select issue with '_'

by Safat Shahin -
Number of replies: 0

The select statement in the SQL selects forcefully removed any '_' in the query.

As an example, 

"select employee as 'profile_field_username'

from prefix_user", this query returns the report as below:

profile field username

username1

username2

.........

The header is forcefully changed to "profile field username" from "profile_field_username".

I figured out the code snippet which is doing it, given below:

moodle/blocks/configurable_reports/reports/sql/report.class.php

The code is given below: (Line 123 - 126)

foreach ($rs as $row) {

                    if (empty($finaltable)) {

                        foreach ($row as $colname => $value) {

                            $tablehead[] = str_replace('_', ' ', $colname);

                        }

                    }


I want to know the reason behind doing that as removing or changing this bit actually solves the problem.

Average of ratings: -