Hello,
Sorry, I searched the forums directly and via Google and found some distantly related posts but none that directly helped me to fix my problem.
I'm writing a new function for a customized version of the face to face module and am oh so close to having it working but I'm getting an SQL error that I can't figure out.
Here is my sql query from the function:
$count = $DB->count_records_sql
('SELECT COUNT(su.userid)
FROM
{facetoface_signups} su
JOIN
{facetoface_signups_status} ss
ON
su.id = ss.signupid
JOIN
{facetoface_sessions} fs
ON
su.sessionid = fs.id
JOIN
{facetoface_sessions_dates} sd
ON
fs.id = sd.sessionid
WHERE
ss.superceded = ?
AND
su.userid = ?
AND
fs.facetoface = ?
AND
ss.statuscode >= 60
AND
FROM_UNIXTIME(sd.timestart), "%%d%%B%%Y" = ?', array(0, $userid, $facetofaceid, $thisdate));
$thisdate is defined at the beginning of the function and is correct as shown in my debug info (pasted below). The two dates (26 March 2014 in this case) are being compared...or so it would seem (one from the variable and the other from the query) but for some reason I'm getting an error.....I have this terrible feeling I'm missing something elementary but I can't figure it out.
Here is the debug and stack trace info:
SELECT COUNT(su.userid)
FROM
mdl_facetoface_signups su
JOIN
mdl_facetoface_signups_status ss
ON
su.id = ss.signupid
JOIN
mdl_facetoface_sessions fs
ON
su.sessionid = fs.id
JOIN
mdl_facetoface_sessions_dates sd
ON
fs.id = sd.sessionid
WHERE
ss.superceded = ?
AND
su.userid = ?
AND
fs.facetoface = ?
AND
ss.statuscode >= 60
AND
FROM_UNIXTIME(sd.timestart), "%%d%%B%%Y" = ?
[array (
0 => 0,
1 => '3',
2 => '1',
3 => '26 March 2014', <-----That's the date from the database.....which is the same as the one above from the variable....
Error code: dmlreadexception
-
- line 441 of /lib/dml/moodle_database.php: dml_read_exception thrown
- line 996 of /lib/dml/mysqli_native_moodle_database.php: call to moodle_database->query_end()
- line 1415 of /lib/dml/moodle_database.php: call to mysqli_native_moodle_database->get_records_sql()
- line 1488 of /lib/dml/moodle_database.php: call to moodle_database->get_record_sql()
- line 1659 of /lib/dml/moodle_database.php: call to moodle_database->get_field_sql()
- line 3097 of /mod/facetoface/lib.php: call to moodle_database->count_records_sql()
- line 157 of /mod/facetoface/renderer.php: call to facetoface_dailycount() //this is my function
- line 193 of /mod/facetoface/view.php: call to mod_facetoface_renderer->print_session_list_table()
- line 102 of /mod/facetoface/view.php: call to facetoface_print_session_list()
Any advice and/or help will be greatly appreciated.
Jason