Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Bug: Column 'timecreated' in where clause is ambiguous.

We joins 2 tables: course and enrol_authorize.
We didn't select course.timecreated, but it gives this error.
  • Loading branch information...
commit fe2bc06329bc8d58bfe8daa995eaed3d0ef89f26 1 parent 58643a8
ethem authored
Showing with 3 additions and 2 deletions.
  1. +3 −2 enrol/authorize/enrol.php
View
5 enrol/authorize/enrol.php
@@ -706,7 +706,7 @@ function cron()
$sql = "SELECT E.*, C.fullname, C.enrolperiod " .
"FROM {$CFG->prefix}enrol_authorize E " .
"INNER JOIN {$CFG->prefix}course C ON C.id = E.courseid " .
- "WHERE (status = '" .AN_STATUS_AUTH. "') " .
+ "WHERE (E.status = '" .AN_STATUS_AUTH. "') " .
" AND (E.timecreated < '$timediffcnf') AND (E.timecreated > '$timediff30')";
if (!$orders = get_records_sql($sql)) {
@@ -875,11 +875,12 @@ function cron_daily()
}
$sorttype = empty($CFG->an_sorttype) ? 'ttl' : $CFG->an_sorttype;
+ $where = "(E.status='". AN_STATUS_AUTH ."') AND (E.timecreated<'$timediffem') AND (E.timecreated>'$timediff30')";
$sql = "SELECT E.courseid, E.currency, C.fullname, C.shortname, " .
"COUNT(E.courseid) AS cnt, SUM(E.amount) as ttl " .
"FROM {$CFG->prefix}enrol_authorize E " .
"INNER JOIN {$CFG->prefix}course C ON C.id = E.courseid " .
- "WHERE $select GROUP BY E.courseid ORDER BY $sorttype DESC";
+ "WHERE $where GROUP BY E.courseid ORDER BY $sorttype DESC";
$courseinfos = get_records_sql($sql);
foreach($courseinfos as $courseinfo) {
Please sign in to comment.
Something went wrong with that request. Please try again.