2
0

my_course_insert.php 1020 B

123456789101112131415161718192021222324252627
  1. <?php
  2. require_once "../config.php";
  3. require_once "../public/_pdo.php";
  4. require_once '../public/function.php';
  5. global $PDO;
  6. PDO_Connect(""._FILE_DB_COURSE_);
  7. $query = "INSERT INTO course (id, title, subtitle, creator, tag, summary, status, cover, teacher, lang , speech_lang ,attachment, 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"] , "" ,$_POST["attachment"] , 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. }
  17. else{
  18. $respond['status']=0;
  19. $respond['message']="成功";
  20. }
  21. echo json_encode($respond, JSON_UNESCAPED_UNICODE);
  22. ?>