From bd3aa224e686dfe46dbaa7616307c117d698b1ea Mon Sep 17 00:00:00 2001 From: Tom Mayfield Date: Fri, 26 May 2023 13:45:00 -0700 Subject: [PATCH] Fix MySQL syntax with Moodle constant for retrieving only one row --- classes/custompage.php | 4 ++-- forms/edit.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/classes/custompage.php b/classes/custompage.php index 516084b..f790f84 100644 --- a/classes/custompage.php +++ b/classes/custompage.php @@ -119,14 +119,14 @@ public static function load($id, $editor = false) { $data = new \stdClass(); if (intval($id) > 0) { - $data = $DB->get_record_sql("SELECT * FROM {local_pages} WHERE id=? LIMIT 1", array(intval($id))); + $data = $DB->get_record_sql("SELECT * FROM {local_pages} WHERE id=?", array(intval($id), IGNORE_MULTIPLE)); } else { // Check url for page name. $main = explode('?', trim($_SERVER['REQUEST_URI'])); $parts = explode("/", trim($main[0])); $url = '%' . end($parts) . '%'; - $page = $DB->get_record_sql("SELECT * FROM {local_pages} WHERE menuname LIKE ? limit 1", array(trim($url))); + $page = $DB->get_record_sql("SELECT * FROM {local_pages} WHERE menuname LIKE ?", array(trim($url)), IGNORE_MULTIPLE); if ($page) { $data = $page; diff --git a/forms/edit.php b/forms/edit.php index d0a07dd..2a055b6 100644 --- a/forms/edit.php +++ b/forms/edit.php @@ -187,7 +187,7 @@ public function validation($data, $files) { */ private function build_html_form() { global $DB; - $usertable = $DB->get_record_sql("select * FROM {user} LIMIT 1"); + $usertable = $DB->get_record_sql("select * FROM {user}", null, IGNORE_MULTIPLE); $records = json_decode($this->_pagedata); // PHP 7.2 count now throws error if items is not countable instead of returning 0. $limit = intval(@count($records));