I'm trying to display sql query on page in drupal 8.2, but I get an error:
The controller must return a response (Object(Drupal\Core\Render\Markup) given).
How should I change the following code?
if ($result = $mysqli->query("SELECT id, discipline, teacher FROM canteach")) {
$output .= "Select вернул " . $result->num_rows . " строк <br />";
}
$mysqli->close();
$header = array('id', 'Discipline', 'Teacher');
$rows = array();
while ($row = $result->fetch_array(MYSQLI_NUM)) {
$rows[] = array($row->id, $row->discipline, $row->teacher);
}
$result->close();
$items_array = array(
'#theme' => 'table',
'#items' => array('header' => $header, 'rows' => $rows),
);
return render($items_array);
fetch_array()
orMYSQLI_NUM
(nor does Drupal 7). Plus, you are not even showing the rest of the code, so we cannot know which method is using the code you are showing.