Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP
Author Message
kguske
Site Admin



Joined: Jun 04, 2004
Posts: 6433

PostPosted: Fri Dec 23, 2005 8:38 am Reply with quote

I'm looking for a way to determine if a table should be created (sort of a self-install), without requiring MySQL. I've thought of selecting a dummy record that is required, but not used. Any other suggestions?

_________________
I search, therefore I exist...
nukeSEO - nukeFEED - nukePIE - nukeSPAM - nukeWYSIWYG
 
View user's profile Send private message
montego
Site Admin



Joined: Aug 29, 2004
Posts: 9457
Location: Arizona

PostPosted: Fri Dec 23, 2005 8:44 am Reply with quote

kguske, I think Raven's Who-Is-Where block does this. Here is how he did it:

Code:


function mysql_table_exists($table) {
   $exists = mysql_query("SELECT 1 FROM `$table` LIMIT 0");
   if ($exists) return true;
   return false;
}
//   mysql_query('drop table '.$prefix.'_wiw_m');
if (!mysql_table_exists($prefix.'_wiw_m')) {
   mysql_query('create table '.$prefix.'_wiw_m (who varchar(20), mn varchar(20)) type=memory') or die('MySQL said: '.mysql_error());
}


So, it does look like he took that approach.

_________________
Where Do YOU Stand?
HTML Newsletter::ShortLinks::Mailer::Downloads and more... 
View user's profile Send private message Visit poster's website
kguske







PostPosted: Fri Dec 23, 2005 9:29 am Reply with quote

Thanks, montego. That approach could be generalized - i.e. it should work even if another database is used, unless there is something database-specific in the create SQL. I'll give it a try...
 
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©