Skip to content

Fix MySQL syntax with Moodle constant for retrieving only one row #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions classes/custompage.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion forms/edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down