[wp-hackers] Plugin Questions

Andy Skelton skeltoac at hotmail.com
Thu May 12 15:14:03 GMT 2005


>1) I'm working on a small plugin that requires an additional database 
>table. Currently I'm using a query like
>SHOW TABLES LIKE 'wp_mytable'
>to check to see if my table already exists and create it if it doesn't. 
>What are others doing to accomplish this?

It sounds like you just want to run a CREATE TABLE one time and never check 
for the table thereafter. You can look into my solution for this in Count My 
Clicks: http://wp-plugins.net/index.php?id=209
Synopsis: In the plugin's description, add a link to the plugin file with a 
special query string. Clicking that link in the Plugins admin page will 
initialize the plugin's tables, settings, or whatever. To make the plugin 
fail silently if the database is missing, you can use check a setting or a 
static file created by the plugin on initialization.

>2) This may be more of a php question. There are occasions where I would 
>like to perform a longer running task in the background (in terms of a 
>minute or two, not hours). I realize that platform,webserver, php 
>configuration can play a big role in what is possible. I've done some 
>reading on using exec or system to perform background tasks. I've also 
>thought of creating a php command line script that could be run from cron 
>and check for work to be done. I was curious if anybody has some real world 
>experience doing this with a plugin.

I'm using the cron table to call several PHP scripts at different intervals 
to update the database at http://blogsoftheday.com and some of those scripts 
can run for several minutes. It was shockingly easy to set up and it has not 
faltered once.

Cheers,
Andy Skelton
http://skeltoac.com

_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar – get it now! 
http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/



More information about the wp-hackers mailing list