PDA

View Full Version : MySQL question


Lea Verou
03-08-2006, 03:08 AM
How can I make my queries that for instance add a table, or a column in an existing table, or drop a table or a column perform it regardless of whether the table or the column exist or not? This would be very useful for install/uninstall codes so that a product can be overwritten or uninstalled regardless if the installation was completed succesfully.
Will just a "@" before the function accomplish this?

Code Monkey
03-08-2006, 01:01 PM
If I get your meaning, then just use incremental install sections by product version number. You have the original installs code under install section with the original install version number. Leave that permanent. Then add changes and additions under new higher version numbers.

As long as the version number is higher than the users current version it will run it. You can check my Articlebot install for an example.

Lea Verou
03-08-2006, 01:06 PM
Yes but small bugfixes do not increase the version number and even if they do, the code will become very complicated after some editions. For the install code I want for instance, if a table/field exists to do nothing. If it doesn't exist to install it, but with an easy way. I don't have the time and courage to write hundreds of lines for just install/uninstall code. :(

Code Monkey
03-08-2006, 01:10 PM
If everyone had mysql 5 you could probably do it easy. Unfortunately.....

I just increment the version number by 0.0.1 for bugfixes and consolidate older version installs as time goes by.

Also. You should be putting your db codes between these vb functions.


$db->hide_errors();

//code here

$db->show_errors();



Then it will do as you want if the user clicks "overwrites on". It will ignore all errors.

Lea Verou
03-08-2006, 04:03 PM
Hmmm I'll try that, thanks :)