22.01.2015, 19:45
Hi guys!
I had a working business system, buying, creating and everything! Now I edited something and it's all messed up!
How can I make that my Internal biz id is the same as MySQL autoincrement primary key? Its like in MySQL is 1, but in script starts as 0, as everything else.
Here are my codes...
Well you get the point... How to make them 1 Internal ID == 1 MYSQL ID, not 0 == 1
I had a working business system, buying, creating and everything! Now I edited something and it's all messed up!
How can I make that my Internal biz id is the same as MySQL autoincrement primary key? Its like in MySQL is 1, but in script starts as 0, as everything else.
Here are my codes...
pawn Код:
cmd:createbiz
{
new ID = spawnedbiz + 1;
GetPlayerPos(playerid,xa,ya,za);
FirmaInfo[ID][EXTX] = xa;
FirmaInfo[ID][EXTY] = ya;
FirmaInfo[ID][EXTZ] = za;
mysql_format(MySQLHandle, Query, sizeof(Query),"INSERT INTO firme ( name, position and stuff) VALUES (not important);
mysql_tquery(MySQLHandle, Query, "OnBizCreate", "i", ID);
}
forward OnBizCreate(idbiz);
public OnBizCreate(idbiz)
{
FirmaInfo[idbiz][IDBiz] = cache_insert_id();
spawnedbiz ++;
printf("New biz - ID: %d", spawnedbiz ); // if is the first one created, it will write "1"
}
forward LoadBiz();
public LoadBiz()
{
new Query[ 256 ];
if(cache_num_rows())
{
for(new i, j = cache_num_rows(); i < j ; i++)
{
FirmaInfo[i][IDBiz] = cache_get_field_content_int(i, "IDBiz"); // This is the first field AKA autoincrement primary key in the table
ReloadBizLabels(i); // if i put here "FirmaInfo[i][IDBiz]" it won't show the first one biz, well the only one when I created so I put it as "i"
spawnedbiz ++;
printf("Debug id biz loadied is %d",FirmaInfo[i][IDBiz]); // "1"