SA-MP Forums Archive
format to string question - 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: format to string question (/showthread.php?tid=315320)



format to string question - lorigio - 02.02.2012

If i wanna doing a query in mysql, i do this

Quote:

new name[10];
name = "lorigio";
new Query[200];
format(Query, sizeof(Query), "update table set var = '%s'", name);
mysql_query(Query);

And after that i said O.o too lines for one query.

I wanna do it likes this
Quote:

new name[10];
name = "lorigio";
mysql_query(format("update table set var = '%s'", name)); <-- format return a string[]

it is possible?


Re: format to string question - [HiC]TheKiller - 02.02.2012

https://sampwiki.blast.hk/wiki/MySQL#mysql_format

There you go.


Re: format to string question - lorigio - 02.02.2012

Quote:

new szDestination[100];
mysql_format(connectionHandle, szDestination, "SELECT * FROM `%s` WHERE `bar` = '%e' AND `foobar` = '%f' LIMIT %d", "foobar", "escape'me\"please", 1.2345, 1337);
// the variable 'szDestination' contains now the formatted query (including the escaped string)
mysql_query(szDestination);

Even this use szDestination[100];
i wanna execute query not store query and then execute it.


Re: format to string question - lorigio - 04.02.2012

bump