The Endless arguments - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: The Endless arguments (
/showthread.php?tid=604292)
The Endless arguments -
mcreed - 03.04.2016
hi, I want to ask for help in the following function.
Basically I want his method of using it:
GuardarCampo (ID, Table, Field1, Value1, Field2, Value2, etc ..);
I have the following code:
PHP код:
stock GuardarCampostr(id,Tabla[], ...)
{
new Args = 2;
new query[256];
new inf_Salida[256];
format(inf_Salida,sizeof(inf_Salida),"UPDATE `%s` SET ",Tabla);
do
{
format(query,sizeof(query),"`%s`=%s,",getarg(Args-1), getarg(Args));
Args+=2;
strcat(inf_Salida,query);
}
while(Args <= numargs()-1);
format(query,sizeof(query),"`%s`=%s WHERE `ID`=%d",getarg(Args-1), getarg(Args),id);
strcat(inf_Salida,query);
printf(inf_Salida);
}
But I have a problem and I print it this way:
pawn Код:
UPDATE `svr_cuentas` SET `s`=Ms,``=M,``=M,``= WHERE `ID`=1
It donot really a lot of use of the endless arguments (...)
Re: The Endless arguments -
PinkFloydLover - 03.04.2016
If you need to use a loop to format all of your SQL fields for queries then you're doing something wrong, you can just manually write them, it's bad practise to have too many fields in a table