From 4e96165e594e3679f4ec00c4122a6532bc56683e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Mudr=C3=A1k?= Date: Mon, 22 Aug 2016 16:29:11 +0200 Subject: [PATCH] MDL-55660 tablelib: Fetch only a single row when auto defining columns In a very rare cases where the columns are not declared explicitly, we want to fetch single row only without a warning raised. This seems like a valid use case for IGNORE_MULTIPLE flag. --- lib/tablelib.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/tablelib.php b/lib/tablelib.php index 3ab007025a0..05b86f57169 100644 --- a/lib/tablelib.php +++ b/lib/tablelib.php @@ -1598,7 +1598,8 @@ class table_sql extends flexible_table { function out($pagesize, $useinitialsbar, $downloadhelpbutton='') { global $DB; if (!$this->columns) { - $onerow = $DB->get_record_sql("SELECT {$this->sql->fields} FROM {$this->sql->from} WHERE {$this->sql->where}", $this->sql->params); + $onerow = $DB->get_record_sql("SELECT {$this->sql->fields} FROM {$this->sql->from} WHERE {$this->sql->where}", + $this->sql->params, IGNORE_MULTIPLE); //if columns is not set then define columns as the keys of the rows returned //from the db. $this->define_columns(array_keys((array)$onerow));