views:

44

answers:

1

I trying to make a realtime stats bar. And I think of using the Long Polling concept.

But when a request is send to php. I need a way of testing if the stats are updated.

Now I can just make a loop with a database query, and test it. But that just doesn't seem right to me :)

Is there a more inexpensive method of testing the database for updates?

A: 

This will depend on how intensive the query for determining whether stats are updated is. If it's a simple (and fast) query, then that would be the best option. If it's an expensive query, change how the stats are updated so you either set a datestamp or have a DB trigger do it for you. No matter what, you're going to need some type of query to check for updates.

And you can't "push" from server to client either, so no matter what you'll need ajax polling so the client initiates the check....

Graza