How to implement dynamic listening database changes?

Source: Internet
Author: User
How to implement dynamic listening database changes?
Want to make a shopping site, want to be when someone buys a product to prompt "Someone buys your goods" such message, but how to listen to the changes in the database? If the database should be a regular query of resources it? (1 times/1s). Thank you, everyone.


------Solution--------------------
I understand the landlord meaning, he means that the current station when someone orders the background staff can immediately get to the next order information, rather than refresh to see.
I currently have the following options,
1, write a mail to send, when there are customers to place a single time when inserting data in the mail sent to the Administrator mail, preferably QQ mail, because QQ can remind, hehe. This way, when someone orders, they immediately know, of course, you can also use text messages (but money, but also delay).
2, the use of JS setinterval every 3 seconds to see if the database has changed, if any, you can do a QQ or Wang Wang's cue tone to prompt the backstage staff have new orders, I do so.
Put down My Code:

var int=setinterval ("Clock ()", 20000);
function Clock () {
$ ("#call_div"). HTML ('
  • Refreshing screen ...
  • ');
    var url = "extend/new_dd.php?cache=" +math.random ();
    $.get (url,function (Result) {
    $ ("#call_div"). HTML (result);
    });
    }

    3, also use JS setinterval but not query database, and when there are customers to order, when inserting data change $_session[odrer_state] inside content is 1, then is the use of JS setinterval every 3 seconds to get content, If it is 1, we do not have the backstage staff have orders, if the backstage has seen the main point of processing and then the $_session[odrer_state] content into 0. The benefit is that database resources are not consumed by too many queries.

    In fact, a lot of methods to see how you use the most suitable. Attach the image of the function of my website
  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.