my_lesson_insert.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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="UPDATE course SET receive_time= ? , modify_time= ? where id = ? ";
  8. PDO_Execute($query,array(mTime(),mTime(),$_POST["course_id"]));
  9. $query = "INSERT INTO lesson (id, course_id, live, replay, title, subtitle , date , duration , creator, tag, summary, status, cover, teacher, attachment , lang , speech_lang , create_time , modify_time , receive_time )
  10. VALUES (? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? )";
  11. $sth = $PDO->prepare($query);
  12. /*
  13. $data = strtotime($_POST["lesson_date"]);
  14. $time = strtotime($_POST["lesson_time"]) - strtotime("today");
  15. $datatime = ($data+$time)*1000;
  16. $duration = strtotime($_POST["duration"]) - strtotime("today");
  17. */
  18. $data = strtotime($_POST["lesson_date"]);
  19. $time = strtotime($_POST["lesson_time"]) - strtotime("today");
  20. $timezone = $_POST["lesson_timezone"];
  21. $datatime = ($data+$time+$timezone*60)*1000;
  22. $duration = strtotime($_POST["duration"]) - strtotime("today");
  23. $sth->execute(array(UUID::v4(), $_POST["course_id"] , $_POST["live"] , $_POST["replay"] ,$_POST["title"] , $_POST["subtitle"] , $datatime , $duration , $_COOKIE["userid"] , $_POST["tag"] ,$_POST["summary"] , 1, $_POST["cover"] ,$_POST["teacher"] , $_POST["attachment"] , $_POST["lang"] , $_POST["speech_lang"] ,mTime() , mTime() , mTime() ));
  24. $respond=array("status"=>0,"message"=>"");
  25. if (!$sth || ($sth && $sth->errorCode() != 0)) {
  26. $error = PDO_ErrorInfo();
  27. $respond['status']=1;
  28. $respond['message']=$error[2];
  29. }
  30. else{
  31. $respond['status']=0;
  32. $respond['message']="成功";
  33. $respond['course_id']=$_POST["course_id"];
  34. }
  35. echo json_encode($respond, JSON_UNESCAPED_UNICODE);
  36. ?>