NoteOnMe博客平台搭建
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

54 rader
1.6 KiB

3 år sedan
  1. <?php
  2. try {
  3. /*$pdo = new PDO('mysql:host=localhost;port=8889;dbname=blog',
  4. 'fred', 'zap');*/
  5. $pdo = new PDO('mysql:host=10.23.243.242;port=3306;dbname=blog',
  6. 'root', 'a15862340183');
  7. } catch (Exception $e) {
  8. echo($e->getMessage());
  9. }
  10. $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  11. /*
  12. GRANT ALL ON blog.* TO 'root'@'%' IDENTIFIED BY 'a15862340183';
  13. CREATE DATABASE blog DEFAULT CHARACTER SET utf8;
  14. CREATE TABLE users (
  15. user_id INT UNSIGNED NOT NULL AUTO_INCREMENT ,
  16. password VARCHAR(128) NOT NULL ,
  17. name VARCHAR(255) NOT NULL ,
  18. PRIMARY KEY(user_id)
  19. )ENGINE=InnoDB DEFAULT CHARSET=utf8;
  20. CREATE TABLE article (
  21. article_id INT UNSIGNED NOT NULL AUTO_INCREMENT ,
  22. user_id INT UNSIGNED NOT NULL,
  23. headline TEXT,
  24. content TEXT,
  25. viewer INT UNSIGNED ,
  26. public varchar(11),
  27. category varchar(128),
  28. PRIMARY KEY(article_id),
  29. CONSTRAINT articc_ibfk_1
  30. FOREIGN KEY (user_id)
  31. REFERENCES users (user_id)
  32. ON DELETE CASCADE ON UPDATE CASCADE
  33. )ENGINE=InnoDB DEFAULT CHARSET=utf8;
  34. CREATE TABLE commentsss (
  35. id INT UNSIGNED NOT NULL AUTO_INCREMENT ,
  36. comment_id INT UNSIGNED NOT NULL,
  37. feedback_id INT UNSIGNED ,
  38. name VARCHAR(128),
  39. user_id INTEGER,
  40. article_id INT UNSIGNED,
  41. content TEXT,
  42. PRIMARY KEY(id),
  43. CONSTRAINT articcc_ibfk_1
  44. FOREIGN KEY (article_id)
  45. REFERENCES article (article_id)
  46. ON DELETE CASCADE ON UPDATE CASCADE
  47. )ENGINE=InnoDB DEFAULT CHARSET=utf8;
  48. */