Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2016
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. register->
  2. insert into users (name, surname, username, password, email, birthday) values ('Test', 'User', 'test_user', '123456', 'test@user.com', '01.01.1980');
  3.  
  4. login->
  5. select u.* from users u where
  6. ( u.username = username_pattern or u.email = email_pattern ) and
  7. (u.password = password_pattern);
  8.  
  9. topics for category ->
  10. select t.* from topics t, topics_categories tc, categories c where
  11. t.id = tc.topic_id and
  12. tc.category_id = c.id;
  13.  
  14. last 10 topics ->
  15. select * from (
  16. select * from topics
  17. order by created_at desc limit 10
  18. ) order by created_at ASC;
  19.  
  20. show topic->
  21. select t.*, c.* form topics t, comments c where
  22. t.id = requested_topic_id and
  23. c.topic_id = t.id;
  24.  
  25. admin panel=> search users bt name, surname or email ->
  26. select u.* from users u where
  27. u.username like pattern or
  28. u.name like pattern or
  29. u.surname like pattern;
  30.  
  31. admin panel=> all users with the requested role ->
  32. select u.* from users u, roles r where
  33. r.id = requested_role_id and
  34. u.role_id = r.id;
  35.  
  36. create topic->
  37. insert into topics (title, content, tags, status) VALUES ('Topic One', 'Content of the first topic', 'tag1, tag2', true);
  38.  
  39. create comment->
  40. insert into comments (content, topic_id, category_id) VALUES ('This is comment's content', 1, 1);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement