![]() |
Our Platinum Sponsors: |
|
#1
|
|||
|
|||
|
Hey All
The question I have relates to some chat software I'm making. At the moment I'm using AJAX <--> PHP <--> MySQL so the AJAX polls the PHP and the PHP backend checks for a new entry in the table, If there's none found it sleeps and then tries again until new data is available. The problem is that the PHP backend has to poll the database every couple of seconds to check for new data. I was wondering if MySQL has Push functionality so that the PHP doesn't have to keep polling. I know this can be done by running an external program on the server and using sockets, although this is distributable software so it's not really an option. Any ideas? I can show some relavant code if needed.
__________________
---------------------------- http://www.mariovisic.com/ - Portfolio http://www.humorlist.net/ - It has stripes |
|
#3
|
|||
|
|||
|
Yeah I was under the impression that mysql didn't have any push features. Polling the DB should work good enough.
I don't really want to use Comet as it has the be distributable. So long polling seems the go ![]() Thanks Botman
__________________
---------------------------- http://www.mariovisic.com/ - Portfolio http://www.humorlist.net/ - It has stripes |
|
#4
|
|||
|
|||
|
No prob. Good luck.
|
|
#5
|
|||
|
|||
|
Does MySQL have triggers yet? If so you could use that to "push" some PHP event.
__________________
Ajax, ASP classic, ASP.NET, Javascript, Perl, PHP consulting (matthew@perthonline.net) |
|
#6
|
|||
|
|||
|
http://dev.mysql.com/doc/refman/5.1/en/triggers.html
According to that, MySQL does have triggers now, and they can be used to call an external program through a UDF. This does require installation of certain libraries to achieve however, so it's not exactly a portable, distributable solution.
__________________
Ben Thomson | www.alfreido.com | www.grandtheftalfreido.com |
|
#7
|
|||
|
|||
|
I think the only trigger conditions are updates, inserts and deletes though.
Sooo... you'd need to use PHP to make a SQL call that triggers MySQL's trigger to call a custom function that calls a remote program and runs some PHP...
|
|
#8
|
||||
|
||||
|
This might be a little from left field, so feel free to shoot me down with "avoiding the question!" but in this case should you be using a database? Why don't you use a XMPP server (like Jabber) as a backend? It is designed for chat after all...
If you need to archive the messages you can always skim a copy off and store that in the database. |
|
#9
|
|||
|
|||
|
Well the software has to be distributable so that's why I can't use Jabber as that would require the user to either have his own server or have it already installed on theirs.
Thanks tho
__________________
---------------------------- http://www.mariovisic.com/ - Portfolio http://www.humorlist.net/ - It has stripes |
![]() |
| Thread Tools | |
| Display Modes | |
|
|