I'm trying to put together some SQL queries using the new DML functions and I'm making a pig's ear of it, but the only error I get is 'Error reading from database' on a white background instead of the course page and this is with debugging turned up to developer level.
What I want is to be able to see the actual SQL query so I can tell whether I got the variables substituted right. Is there any way to make it do this?
In reply to Matt Gibson
Re: How do I get verbose SQL diagnostic stuff out of Moodle 2.0
by Matt Gibson -
I suppose it might help to add the actual query too.
$sql = 'SELECT COUNT (go.id)
FROM {grade_oucomes_courses} go
JOIN {course} c
ON go.courseid = c.id
WHERE c.id = :courseid';
if (!$DB->count_records_sql($sql, array('courseid' => $courseid))) {
$errorstoreturn[] = 'This course has no outcomes associated with it yet. Fix this in the course settings block.';
}
In reply to Matt Gibson
Re: How do I get verbose SQL diagnostic stuff out of Moodle 2.0
by Matt Gibson -
OK, for future reference, it works if you take the space away between COUNT and the bracket.
This definitely needs a better error message.
This definitely needs a better error message.
In reply to Matt Gibson
Re: How do I get verbose SQL diagnostic stuff out of Moodle 2.0
by Matt Gibson -
Now that I've sorted the errors, it turns up like this:
Debug info: FUNCTION assmoodle2.COUNT does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual
SELECT COUNT (go.id)
FROM mdl_grade_outcomes_courses go, mdl_course c
WHERE go.courseid=c.id
AND c.id=?
[array (
0 => 2,
)]
Which still seems not very useful.
MDL-22346
Debug info: FUNCTION assmoodle2.COUNT does not exist. Check the 'Function Name Parsing and Resolution' section in the Reference Manual
SELECT COUNT (go.id)
FROM mdl_grade_outcomes_courses go, mdl_course c
WHERE go.courseid=c.id
AND c.id=?
[array (
0 => 2,
)]
Which still seems not very useful.
MDL-22346
In reply to Matt Gibson
Re: How do I get verbose SQL diagnostic stuff out of Moodle 2.0
by Paul Holden -
Matt - the error is in your SQL code (as mentioned in the bug report), and the error message is being returned by the database. Run the same query from a mysql client to check
In reply to Paul Holden
Re: How do I get verbose SQL diagnostic stuff out of Moodle 2.0
by Matt Gibson -
Ah yes, same error. I've now read up on the MySQL IGNORE SPACE option, which it pointed to, so I see why it's happening, but it's confusing as there's no mention of whitespace in the error message (other developers here were also stumped). Probably wouldn't have mattered as much if I hadn't messed up my debugging settings accidentally of course.
In reply to Matt Gibson
Re: How do I get verbose SQL diagnostic stuff out of Moodle 2.0
by Matt Gibson -
I've now found that the same useless error appears if you misspell one of the column names. How can I get better debugging output? It's driving me nuts!
In reply to Matt Gibson
Re: How do I get verbose SQL diagnostic stuff out of Moodle 2.0
by Tim Hunt -
Have you got 'Display debug messages' turned on, or are the messages just going to your PHP log files?
In reply to Tim Hunt
Re: How do I get verbose SQL diagnostic stuff out of Moodle 2.0
by Matt Gibson -
Yes, the 'display debug messages' setting is on, but I've just realised when I double checked that I restored from a DB backup yesterday and the debug level has been set back to ALL from DEVELOPER. Messages were indeed in the log files and they now display on screen as I expected.
Thanks for the reminder!
I feel a bit of a fool now
Thanks for the reminder!
I feel a bit of a fool now
