如何仅为输出更改列名?

时间:2015-04-06 16:01:40

标签: php sql

我只需要在输出中更改此列的名称:

function profile_display_hierarchy_fields($userid) {
global $OUTPUT, $DB;
$sql = "SELECT p.fullname as pos, o.fullname as org, u.id as manid,
            " . $DB->sql_fullname('u.firstname', 'u.lastname') . " AS fullname
            FROM {pos_assignment} pa
                LEFT JOIN {pos} p ON pa.positionid = p.id
                LEFT JOIN {org} o ON pa.organisationid = o.id
                LEFT JOIN {user} u ON u.id = pa.managerid
            WHERE pa.userid = ? AND pa.type = 1 ";

$record = $DB->get_record_sql($sql, array($userid), IGNORE_MULTIPLE);

//if (isset($record->pos)) {
echo '<tr>';
    echo html_writer::tag('td', get_string('position', 'totara_hierarchy'));
    echo html_writer::tag('td', $record->pos);
//}td

if (isset($record->org)) {
    //echo html_writer::tag('td', get_string('organisation', 'totara_hierarchy'));
   //echo html_writer::tag('td', $record->org);
}

//if (isset($record->manid)) {
    $manurl = html_writer::link(new moodle_url('/user/profile.php', array("id" => $record->manid)), $record->fullname);
echo '<tr>';
    echo html_writer::tag('td', get_string('manager', 'totara_hierarchy'));
    echo html_writer::tag('td', $manurl);
//}

}

我将最后一部分的'manager`更改为'supervisor',但是主管在结果中以[[supevisor]]结束。我可以在没有[[]]显示的情况下更改输出上的列名称。感谢。

0 个答案:

没有答案