Advertisement
Tyler_Elric

Untitled

Oct 1st, 2012
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. if
  2. isnull((select lastClick
  3. from clicks
  4. where adoptableID=new.adoptableID
  5. and userID=new.userID)) then
  6. insert into clicks(userID,adoptableID,lastClick)
  7. values(new.userID,new.adoptableID,new.lastClick)
  8. elseif addtime(
  9. (select lastClick from clicks
  10. where adoptable.ID=new.adoptableID
  11. and userID=new.userID), '24:00') <= CURRENT_TIMESTAMP
  12. then
  13. update clicks
  14. set lastClick=CURRENT_TIMESTAMP
  15. where userID=new.userID
  16. and adoptableID=new.adoptableID;
  17. else
  18. signal sqlstate '45000' set message_text='You must wait one day between clicks.';
  19. END IF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement