Absolutely it makes sense.
Thanks for the answer too.
That is the issue. My primary keys match exactly.
They are supposed to do so.
Here is the scenerio so you have a proper understanding of what we are doing here.
Grogk walks into the bank and buys some stocks. 3 @ 6.000gp and 2 @ 50.000gp
Step 1:
Collect the player login. character name, tag of item, and number of items from DB "A"
Step 2:
Place that info in DB "B" and delete them from DB "A"
Step 3:
Run some dice roll calculations on them that change the blueprint resref
Step 4: (this is where it mucks up)
Put the new items in DB "A"
as chance would have it Grogk now has 1 stock @ 6.000, 1 @ 60.000, 1 @ 50.000 and 2 @ 9,000
Everything writes back to the DB fine except the second 9,000gp stock because it is a duplicate entry -
Exactly the same as the first... as it should be... which is fine...
Except it throws a duplicate entry error.
No problem. I am fine with that.
However I don't want Grogk to lose his hard earned GP.
So I need to catch that error and if caught then I need to read from DB "A" the count of the duplicate entry items.
(in this case it is one, we were given that info but there may be multiples in the future.)
I don't have a problem pulling out the info I need or writing the new values.
The problem I have is finding out if the query was a success.
Given:
//////////////////////////////////////////////
int SQL_ERROR = 0;
int SQL_SUCCESS = 1;
////////////////////////////////////////////
from aps_include
Can I just check with this if statement:
////////////////////////////////////////////
if (SQL_SUCCESS = 0)
///////////////////////////////////////////
or is there a better way to check for a duplicate entry error
or
is there such a thing as
//////////////////////////////////////////////////////////////////////
try()
{
run function
}
catch()
{
do something else when function fails
}
//////////////////////////////////////////////////////////////////////////
or
SqlQuery = "INSERT INTO vult_items SET ua_string = 'ua_string'"
string result = mysql_query(
[code]SqlQuery [/code]);
if(!result){
fix stuff here;
}
or
is there a way to use MySQL SQLSTATE
with
SIGNAL
Modifié par Supreme_Pizza, 25 janvier 2013 - 11:51 .