浏览代码

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

Yannick Warnier 11 年之前
父节点
当前提交
0034acca69
共有 1 个文件被更改,包括 14 次插入13 次删除
  1. 14 13
      main/coursecopy/classes/CourseBuilder.class.php

+ 14 - 13
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);
         }