Fix SQL error when backuping course with empty thematic plan - refs #6827

1.9.x
Yannick Warnier 11 years ago
parent bc15891256
commit 0034acca69
  1. 27
      main/coursecopy/classes/CourseBuilder.class.php

@ -975,19 +975,20 @@ class CourseBuilder
}
}
//$sql = 'SELECT * FROM '.$table_thematic_plan.' WHERE c_id = '.$course_id.' AND thematic_id = '.$row['id'];
$sql = "SELECT tp.*
FROM $table_thematic_plan tp
INNER JOIN $table_thematic t ON (t.id=tp.thematic_id)
WHERE t.c_id = $course_id AND
tp.c_id = $course_id AND
thematic_id = {$row['id']} AND
tp.id IN (".implode(', ', $thematic_plan_id_list).") ";
$result = Database::query($sql);
while ($sub_row = Database::fetch_array($result,'ASSOC')) {
$thematic->add_thematic_plan($sub_row);
if (count($thematic_plan_id_list) > 0) {
$sql = "SELECT tp.*
FROM $table_thematic_plan tp
INNER JOIN $table_thematic t ON (t.id=tp.thematic_id)
WHERE t.c_id = $course_id AND
tp.c_id = $course_id AND
thematic_id = {$row['id']} AND
tp.id IN (".implode(', ', $thematic_plan_id_list).") ";
$result = Database::query($sql);
while ($sub_row = Database::fetch_array($result,'ASSOC')) {
$thematic->add_thematic_plan($sub_row);
}
}
$this->course->add_resource($thematic);
}

Loading…
Cancel
Save