Undoing Greg's UNION hack ... it was causing problems on Mysql 3
This commit is contained in:
+3
-34
@@ -283,41 +283,11 @@ function journal_get_participants($journalid) {
|
||||
}
|
||||
|
||||
// SQL FUNCTIONS ///////////////////////////////////////////////////////////////////
|
||||
function supports_union(){
|
||||
# not all databases support UNION. Adodb doesn't seem to keep track of which do.
|
||||
# this function should probably be moved to datalib once it has been thouroughly tested.
|
||||
$qry = "SELECT 'a' as a UNION SELECT 'b' as a'";
|
||||
$test = get_records_sql($qry);
|
||||
return ($test['b']->a = 'b');
|
||||
}
|
||||
|
||||
function journal_get_users_done($journal) {
|
||||
global $CFG;
|
||||
if(supports_union()) {
|
||||
# Yay! The database supports UNION, so we can use this fast query
|
||||
return get_records_sql ("(SELECT u.*, j.modified
|
||||
FROM {$CFG->prefix}journal_entries j,
|
||||
{$CFG->prefix}user u,
|
||||
{$CFG->prefix}user_students s
|
||||
WHERE j.userid = u.id
|
||||
AND s.userid = u.id
|
||||
AND j.journal = $journal->id
|
||||
AND s.course = $journal->course)
|
||||
|
||||
UNION
|
||||
|
||||
(SELECT u.*, j.modified
|
||||
FROM {$CFG->prefix}journal_entries j,
|
||||
{$CFG->prefix}user u,
|
||||
{$CFG->prefix}user_teachers t
|
||||
WHERE j.userid = u.id
|
||||
AND t.userid = u.id
|
||||
AND j.journal = $journal->id
|
||||
AND t.course = $journal->course)
|
||||
ORDER BY j.modified DESC");
|
||||
} else {
|
||||
# Poo! The database doesn't support UNION, so we are going to use this ugly hack
|
||||
$s_journals = get_records_sql ("SELECT u.*
|
||||
$studentjournals = get_records_sql ("SELECT u.*
|
||||
FROM {$CFG->prefix}journal_entries j,
|
||||
{$CFG->prefix}user u,
|
||||
{$CFG->prefix}user_students s
|
||||
@@ -327,7 +297,7 @@ function journal_get_users_done($journal) {
|
||||
AND s.course = $journal->course
|
||||
ORDER BY j.modified DESC");
|
||||
|
||||
$t_journals = get_records_sql ("SELECT u.*
|
||||
$teacherjournals = get_records_sql ("SELECT u.*
|
||||
FROM {$CFG->prefix}journal_entries j,
|
||||
{$CFG->prefix}user u,
|
||||
{$CFG->prefix}user_teachers t
|
||||
@@ -336,8 +306,7 @@ function journal_get_users_done($journal) {
|
||||
AND j.journal = $journal->id
|
||||
AND t.course = $journal->course)
|
||||
ORDER BY j.modified DESC");
|
||||
return(array_merge($s_journals, $t_journals));
|
||||
}
|
||||
return(array_merge($studentjournals, $teacherjournals));
|
||||
}
|
||||
|
||||
function journal_get_unmailed_graded($cutofftime) {
|
||||
|
||||
Reference in New Issue
Block a user