my_lesson_insert.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435
  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. $data = strtotime($_POST["lesson_date"]);
  13. $time = strtotime($_POST["lesson_time"]) - strtotime("today");
  14. $datatime = ($data+$time)*1000;
  15. $duration = strtotime($_POST["duration"]) - strtotime("today");
  16. $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() ));
  17. $respond=array("status"=>0,"message"=>"");
  18. if (!$sth || ($sth && $sth->errorCode() != 0)) {
  19. $error = PDO_ErrorInfo();
  20. $respond['status']=1;
  21. $respond['message']=$error[2];
  22. echo "<div style=''>Lesson 数据添加失败:{$error[2]}</div>";
  23. }
  24. else{
  25. $respond['status']=0;
  26. $respond['message']="成功";
  27. echo "<div style=''>Lesson 数据添加成功</div>";
  28. }
  29. //echo json_encode($respond, JSON_UNESCAPED_UNICODE);
  30. ?>