DragonPrime - LoGD Resource Community
Welcome Guest
  • Good evening, Guest.
    Please log in, or register.
  • July 20, 2019, 05:13:19 PM
Home Forums News Downloads Login Register Advanced Search
* * *
DragonPrime Menu
Login
 
 
Resource Pages
Search

Pages: [1]   Go Down
  Print  
Author Topic: Checking if a column exists  (Read 3538 times)
0 Members and 1 Guest are viewing this topic.
kickme
Global Moderator
Mod God
*****
Offline Offline

Posts: 1589


Yay for elephants!


View Profile WWW
« on: November 25, 2005, 12:50:13 PM »

How would I check if a column exists in a table?

I'm used to get a 'Column doesn't exist' error, but now I get a 'Duplicate column name' error

At the moment, I'm checking if the column is empty.
« Last Edit: November 25, 2005, 12:53:24 PM by kickme » Logged

Waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka
Nightborn
Guest
« Reply #1 on: November 25, 2005, 12:54:57 PM »

one suggestion: NEVER meddle with the accounts table...

either use the module prefs or settings table...

or create one on your own.

updates won't be nice to your work otherwise...
Logged
kickme
Global Moderator
Mod God
*****
Offline Offline

Posts: 1589


Yay for elephants!


View Profile WWW
« Reply #2 on: November 25, 2005, 12:59:09 PM »

one suggestion: NEVER meddle with the accounts table...

either use the module prefs or settings table...

or create one on your own.

updates won't be nice to your work otherwise...
Its with the bounty table.
Due to Boofo finding a error with my clan add-on, I need to check if the 'clan' column exists, then, if it doesn't, add it.
« Last Edit: November 25, 2005, 12:59:37 PM by kickme » Logged

Waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka
Nightborn
Guest
« Reply #3 on: November 25, 2005, 01:02:45 PM »

bounty is a core table.

that's what I said. the module you gave altered the dag module. that's where the error was.

I would store that "clan" in the module prefs or settings table. otherwise (I don't know if its for the bounty table, Kendaer knows more) a new version will eliminate that column.

I *strongly* advise you to either use own tables or set them as prefs or settings.
Logged
Sichae
iMod God
SVN Users
Mod God
*
Offline Offline

Posts: 3458


If ya didn't get it by now... you're hopeless...


View Profile WWW
« Reply #4 on: November 25, 2005, 01:11:01 PM »

Code:
$sql = "SHOW COLUMNS FROM ".db_prefix("bounty")." LIKE 'clan'";
$res = db_query($sql);
if (db_num_rows($res) == 0){    
    db_query("ALTER TABLE ".db_prefix("bounty")." ADD clan tinyint(4)");
   // supposing you are going to be using the clanid
}
That is how it could be done.
« Last Edit: November 25, 2005, 01:13:36 PM by Sichae » Logged

If you didn't understand anything in the above post, don't try to attempt anything suggested.

kickme
Global Moderator
Mod God
*****
Offline Offline

Posts: 1589


Yay for elephants!


View Profile WWW
« Reply #5 on: November 25, 2005, 01:11:26 PM »

That would be hard, as my module adds to the files, but I could just make a second bounty table. I also figuried how to check if the column exist.
Logged

Waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka
kickme
Global Moderator
Mod God
*****
Offline Offline

Posts: 1589


Yay for elephants!


View Profile WWW
« Reply #6 on: November 25, 2005, 01:15:20 PM »

Heh. My way was a bit more complicated than that.
Logged

Waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka waka
Pages: [1]   Go Up
  Print  
 
Jump to:  


*
DragonPrime Notices
Version 1.1.2 is the current supported version and is available for download.

Support Us
No funds raised yet this year
Your help is greatly appreciated!
Recent Topics
DragonPrime LoGD
Who's Online
116 Guests, 0 Users
Home Forums News Downloads Login Register Advanced Search