Jump to content

Archived

This topic is now archived and is closed to further replies.

phporcaffeine

I need a creative solution

Recommended Posts

Here is what I need:

I have an application where a user creates a MySQL record based on HTML <form> input. In the from the user selects an option to be reminded about the record at X interval.

I need a creative solution to creating the "popup reminder" I am speaking about.

I could use AJAX for for a 'real-time' effect, but depending on the amount of records it could become a huge SQL call that is done through AJAX which would null the 'real-time' effect and be a huge resource hit.

The other option that comes to mind is just do a query at each page load but that requires the user to first 'do-something' before the reminder popup is checked, which is how the client / server architecture works - I realize that.

The problem is that I 'still have to make it work'.

So, does anyone have an ideas, work-arounds or creative solutions?

Share this post


Link to post
Share on other sites
Why would doing it in ajax become nullify the "real time" part of ajax? If the script is returning a huge amount of results, then just use ajax to check and see if there are alerts to view, if there is, then give the user a message, if not, then leave them alone.

Ajax has nothing to do with the actual query...it's merely displaying the results. Your server is doing the query.

Share this post


Link to post
Share on other sites
[!--quoteo(post=357164:date=Mar 21 2006, 08:30 PM:name=hitman6003)--][div class=\'quotetop\']QUOTE(hitman6003 @ Mar 21 2006, 08:30 PM) [snapback]357164[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Why would doing it in ajax become nullify the "real time" part of ajax? If the script is returning a huge amount of results, then just use ajax to check and see if there are alerts to view, if there is, then give the user a message, if not, then leave them alone.

Ajax has nothing to do with the actual query...it's merely displaying the results. Your server is doing the query.
[/quote]


Let me define further -

I realize that AJAX is nothing more than a handful of JavaScript and a pinch of XML, it's not the AJAX that I am worried about - AJAX is just the conduit.

Here is what I am worried about:

8000 + MySQL records

$sql = mysql_query("SELECT * FROM tbl_name WHERE reminder = ' pre determined interval '");

while ($row = mysql_fetch_array($SQL)) {

$results_array[] = $row['id'];

}

Now, if I have AJAX run when the onFocus, onLoad ....etc event fires and then just continue to run (in order to be truly accurate it would have to continually run because as the seconds tick by on the server an "interval" for one of the records may be reached) PHP would be "asked" to re-run that query - over & over & over & over & over, which is where the resource hit comes in to play.

PHP won't "remember" the query results for the next time that the xmlhttpRequest object calls the script so the only option would be for PHP to re-run the query when it is called again by the xmlhttpRequest object.

When I say "continually run" I mean that the xmlhttpRequest object would have to call PHP once every 1-2 seconds. So as long as the user(s) were camped on the page that has AJAX - it would look like a non-stop MySQL call to the server, then multiply that effect * X users and your in for some real issues.

If the databased ever reached the point where the query took more than 1-2 seconds to run then it would be out of sync with the time it took the xmlhttpRequest object to call and thus the "reminder" of 15 minutes after 2pm might be 17 or 18 minutes after 2pm

If I was only talking about 1-2 records and only 1-2 concurrent connections it wouldn't be an issue.

I am trying to achieve the effect of an asynchronous "reminder", similar to the effect of a "Calendar/Event" alarm and it may be that this just isn't possible.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.