IMprovement to get_records

IMprovement to get_records

by Tim Hunt -
Number of replies: 1
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
You know those really annoying and hard to find bugs you get when you call get_records with a query where the first column is not unique, and so all the records overwrite each other in the array you get back. For example:
$trole = get_records_sql("SELECT roleid,capability,permission
 FROM {$CFG->prefix}role_capabilities
 WHERE roleid = $roleid");
to pick the example I have just tracked down to backup/restore_form.php.

Well, sam pointed out to me that it should be possible to output a developer debug message when this happens, and indeed it is. I have just implemented this on the 1.9 stable branch and HEAD. MDL-12438 is the bug.
Average of ratings: -