[wp-hackers] Plugin Questions

Marco Bonetti mbonetti at gmail.com
Thu May 12 16:42:17 GMT 2005

> 1) I'm working on a small plugin that requires an additional database
> table. Currently I'm using a query like

Here is what I use, which I shall call the "fire query first, recurse
as needed" approach.

(Note: pseudo-code)

function queryWrapper($sql,$recurse=true) {

 if (($ret = doActualQuery($sql)) != null) {
   // success!
   return $ret;
 } elseif ($recurse && createTables()) {
   // recurse and try _once_ again on the
   // newly created tables
   return queryWrapper($sql, false);
 } else {
   // second attempt, or we couldn't create
   // tables: fail.
   die("couldn't create table!");

Hope this makes sense!


 Gregarius - http://gregarius.net
 Free, web-based feed aggregator

More information about the wp-hackers mailing list