Big format mysql
#1

What I do with this big format ?
pawn Код:
new
        Placa = random(255255), carroID;
   
mysql_query("INSERT INTO veiculos (id, dono, modelo, x, y, z, a, cor1, cor2, mod1, mod2, mod3, mod4, mod5, mod6, mod7, mod8, mod9, mod10, mod11, mod12, trancado, placa, alarme, imobiliser, insurances, factionid, faction, spawnado) VALUES (NULL, '%s', %d, %f, %f, %f, %f, %d, %d, NULL, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, %d, %d, %d, %d, %d, %d, %d, %d)", pName(playerid),modeloid, concessionariaSpawn_X, concessionariaSpawn_Y, concessionariaSpawn_Z, concessionariaSpawn_A, COR_PADRAO, COR_PADRAO, 1, Placa, 1, 1, START_INSURANCE, FACTION_CIVIL, 0, 0);
And How I get the ID will be generate?
pawn Код:
mysql_query("SELECT id FROM veiculos WHERE dono = '%s'", pName(playerid));
    mysql_fetch_field_row(carroID, "id");
Is this to get the ID /\ ?

Thanks for reply!

+rep for help
Reply
#2

bump
Reply
#3

pawn Код:
new newly_created_id = mysql_insert_id();
after the query has been executed and before the connection is closed.
Reply
#4

Thanks with the ID problem. +Rep

The big query problem continues..

Thanks .
Reply
#5

Quote:
Originally Posted by Ricop522
Посмотреть сообщение
Thanks with the ID problem. +Rep

The big query problem continues..

Thanks .
Format it into a string first you can't pass variables like that from the function itself afaik.
Reply
#6

Like this ?
pawn Код:
format(ricopStr, sizeof(ricopStr), "INSERT INTO veiculos (id, dono, modelo, x, y, z, a, cor1, cor2, mod1, mod2, mod3, mod4, mod5, mod6, mod7, mod8, mod9, mod10, mod11, mod12, trancado, placa, alarme, imobiliser, insurances, factionid, faction, spawnado) VALUES (NULL, '%s', %d, %f, %f, %f, %f, %d, %d, NULL, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, %d, %d, %d, %d, %d, %d, %d, %d)", pName(playerid),modeloid, concessionariaSpawn_X, concessionariaSpawn_Y, concessionariaSpawn_Z, concessionariaSpawn_A, COR_PADRAO, COR_PADRAO, 1, Placa, 1, 1, START_INSURANCE, FACTION_CIVIL, 0, 0);
    mysql_query(ricopStr);
Reply
#7

Quote:
Originally Posted by Ricop522
Посмотреть сообщение
Like this ?
pawn Код:
format(ricopStr, sizeof(ricopStr), "INSERT INTO veiculos (id, dono, modelo, x, y, z, a, cor1, cor2, mod1, mod2, mod3, mod4, mod5, mod6, mod7, mod8, mod9, mod10, mod11, mod12, trancado, placa, alarme, imobiliser, insurances, factionid, faction, spawnado) VALUES (NULL, '%s', %d, %f, %f, %f, %f, %d, %d, NULL, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, %d, %d, %d, %d, %d, %d, %d, %d)", pName(playerid),modeloid, concessionariaSpawn_X, concessionariaSpawn_Y, concessionariaSpawn_Z, concessionariaSpawn_A, COR_PADRAO, COR_PADRAO, 1, Placa, 1, 1, START_INSURANCE, FACTION_CIVIL, 0, 0);
    mysql_query(ricopStr);
Yes, you might get "input line too long" from the compiler, if so just put the variables on a new line.
Reply
#8

and for the null values, dont include the column or the null in it at all, mysql doesn't need all the values at one time if you make sure the default setting for that column is null
Reply
#9

Is this correctly?

pawn Код:
new
        Placa = random(255255), carroID, ricopStr[218], ricopStr2[144], ricopStr3[362];
    format(ricopStr, sizeof(ricopStr), "INSERT INTO veiculos (id, dono, modelo, x, y, z, a, cor1, cor2, mod1, mod2, mod3, mod4, mod5, mod6, mod7, mod8, mod9, mod10, mod11, mod12, trancado, placa, alarme, imobiliser, insurances, factionid, faction, spawnado) ");
    format(ricopStr2, sizeof(ricopStr2), "VALUES (NULL, '%s', %d, %f, %f, %f, %f, %d, %d, 0, 0,0,0,0,0,0,0,0,0,0,0, %d, %d, %d, %d, %d, %d, %d, %d)", pName(playerid),modeloid, concessionariaSpawn_X, concessionariaSpawn_Y, concessionariaSpawn_Z, concessionariaSpawn_A, COR_PADRAO, COR_PADRAO, 1, Placa, 1, 1, START_INSURANCE, FACTION_CIVIL, 0, 0);
    format(ricopStr3, 362, "%s%s", ricopStr, ricopStr2);
    mysql_query(ricopStr3);
Reply
#10

I should have added, when you remove the null values, be sure to remove the coresponding column value.

Example, you had a null value for the id column, so remove the id column also, MySQL will just assume that as null if you don't send a value
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)