my_course_insert.php 1.1 KB

123456789101112131415161718192021222324252627
  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 course (id, title, subtitle, creator, tag, summary, status, cover, teacher, lang , speech_lang , lesson_num , create_time , modify_time , receive_time )
  8. VALUES (? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? )";
  9. $sth = $PDO->prepare($query);
  10. $sth->execute(array(UUID::v4() ,$_POST["title"] , $_POST["subtitle"] , $_COOKIE["userid"] , $_POST["tag"] ,$_POST["summary"] , 1, $_POST["cover"] ,$_POST["teacher"] , $_POST["lang"] , "" , 0 ,mTime() , mTime() , mTime() ));
  11. $respond=array("status"=>0,"message"=>"");
  12. if (!$sth || ($sth && $sth->errorCode() != 0)) {
  13. $error = PDO_ErrorInfo();
  14. $respond['status']=1;
  15. $respond['message']=$error[2];
  16. echo "<div style=''>Course 数据添加失败:{$error[2]}</div>";
  17. }
  18. else{
  19. $respond['status']=0;
  20. $respond['message']="成功";
  21. echo "<div style=''>Course 数据添加成功</div>";
  22. }
  23. //echo json_encode($respond, JSON_UNESCAPED_UNICODE);
  24. ?>