my_lesson_update.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. require_once "../path.php";
  3. require_once "../public/_pdo.php";
  4. require_once '../public/function.php';
  5. global $PDO;
  6. PDO_Connect("sqlite:"._FILE_DB_COURSE_);
  7. $query="SELECT course_id from lesson where id = ? ";
  8. $course_id = PDO_FetchOne($query,array($_POST["lesson"]));
  9. $query="UPDATE course SET receive_time= ? , modify_time= ? where id = ? ";
  10. PDO_Execute($query,array(mTime(),mTime(),$course_id));
  11. $query="UPDATE lesson SET title = ? , subtitle = ? , date = ? , duration = ? , live = ? , replay = ? , summary = ? , teacher = ? , receive_time= ? , modify_time= ? where id = ? ";
  12. $sth = $PDO->prepare($query);
  13. $data = strtotime($_POST["lesson_date"]);
  14. $time = strtotime($_POST["lesson_time"]) - strtotime("today");
  15. $timezone = $_POST["lesson_timezone"];
  16. $datatime = ($data+$time+$timezone*60)*1000;
  17. $duration = strtotime($_POST["duration"]) - strtotime("today");
  18. $sth->execute(array($_POST["title"] , $_POST["subtitle"] ,$datatime, $duration , $_POST["live"] , $_POST["replay"] , $_POST["summary"] , $_POST["teacher"] , mTime() , mTime() , $_POST["lesson"]));
  19. $respond=array("status"=>0,"message"=>"");
  20. if (!$sth || ($sth && $sth->errorCode() != 0)) {
  21. $error = PDO_ErrorInfo();
  22. $respond['status']=1;
  23. $respond['message']=$error[2];
  24. echo "<div style=''>Lesson 数据修改失败:{$error[2]}</div>";
  25. }
  26. else{
  27. $respond['status']=0;
  28. $respond['message']="成功";
  29. echo "<div style=''>Lesson 数据修改成功</div>";
  30. echo $d=strtotime("today");
  31. echo strtotime($_POST["lesson_date"])."<br>";
  32. echo strtotime($_POST["lesson_time"])."<br>";
  33. echo (strtotime($_POST["duration"]) - $d)."<br>";
  34. }
  35. //echo json_encode($respond, JSON_UNESCAPED_UNICODE);
  36. ?>