Port80 Forums Fast Hit Web Hosting

Our Platinum Sponsors:


Go Back   Port80 Forums > Development & Code > php & mySQL

Reply
 
Thread Tools Display Modes
  #1  
Old 03-02-2009, 12:12 PM
cro_crx cro_crx is offline
Junior Member
 
Join Date: Feb 2009
Location: Perth, Western Australia
Age: 25
Posts: 9
cro_crx is on a distinguished road
Default MySQL Push without sockets

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
Reply With Quote
  #2  
Old 03-02-2009, 02:48 PM
Botman Botman is offline
Senior Member
AWIA Member
 
Join Date: May 2007
Location: Perth
Posts: 113
Botman is on a distinguished road
Default

The only thing I can think of is Comet... but you would still need to poll the DB.
Reply With Quote
  #3  
Old 03-02-2009, 04:08 PM
cro_crx cro_crx is offline
Junior Member
 
Join Date: Feb 2009
Location: Perth, Western Australia
Age: 25
Posts: 9
cro_crx is on a distinguished road
Default

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
Reply With Quote
  #4  
Old 03-02-2009, 04:55 PM
Botman Botman is offline
Senior Member
AWIA Member
 
Join Date: May 2007
Location: Perth
Posts: 113
Botman is on a distinguished road
Default

No prob. Good luck.
Reply With Quote
  #5  
Old 04-02-2009, 12:57 PM
indhyper indhyper is offline
Senior Member
 
Join Date: Sep 2003
Location: Perth
Posts: 673
indhyper is on a distinguished road
Default

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)
Reply With Quote
  #6  
Old 04-02-2009, 02:45 PM
Alfreido Alfreido is offline
Member
 
Join Date: Oct 2007
Location: Perth, Western Australia
Posts: 36
Alfreido is on a distinguished road
Default

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
Reply With Quote
  #7  
Old 05-02-2009, 10:10 AM
Botman Botman is offline
Senior Member
AWIA Member
 
Join Date: May 2007
Location: Perth
Posts: 113
Botman is on a distinguished road
Default

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...
Reply With Quote
  #8  
Old 05-02-2009, 12:26 PM
madpilot's Avatar
madpilot madpilot is offline
Senior Member
AWIA Member
 
Join Date: Nov 2002
Location: Perth
Posts: 1,743
madpilot is on a distinguished road
Default

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.
Reply With Quote
  #9  
Old 09-02-2009, 12:24 AM
cro_crx cro_crx is offline
Junior Member
 
Join Date: Feb 2009
Location: Perth, Western Australia
Age: 25
Posts: 9
cro_crx is on a distinguished road
Default

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
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +8. The time now is 08:15 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.