my_lesson_insert.php 1.5 KB

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