Raised This Month: $ Target: $400
 0% 

if sql table ENTERY exist olny Update else insert - how to do this


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
pRED*
Join Date: Dec 2006
Old 05-20-2007 , 00:58   Re: if sql table ENTERY exist olny Update else insert - how to do this
Reply With Quote #2

I've never done DBI (only SQLx) so I'm not entirely sure but..

When you run the UPDATE query it should return an error code. There will be a specific code that only happens when the query failed but the connection worked (eg That line in the table doesn't exist).

http://www.amxmodx.org/funcwiki.php?go=func&id=210
Using that you should be able to get a return value from dbi_query so you want something like this (might need testing, it's just a guess)

Code:
new return = dbi_query(dbc, "UPDATE zbkcommunity SET Spieler=%i, MaximaleSpieler=%i WHERE Server=^"%s^"",Spieler,MaximaleSpieler,Server) if (num<0) //If num is less than 0 (failed)) {     dbi_query(dbc, "Insert INTO zbkcommunity VALUES ('%s', %i, %i)",Server,Spieler,MaximaleSpieler) }

If that doesn't work try if num==0 instead
pRED* is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 10:42.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode