Converting INI To Mysql in an easier way. - 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: Converting INI To Mysql in an easier way. (
/showthread.php?tid=639526)
Converting INI To Mysql in an easier way. -
StrikerZ - 19.08.2017
Well, recently I thought to update my old script to mysql, what I thought to do was
PHP код:
stock INI_Int(What[],Variable)
{
Variable = cache_get_field_content_int(0, What);
}
Would this work? I guess it'll.
Re: Converting INI To Mysql in an easier way. -
Vince - 19.08.2017
It won't do anything because the variable isn't passed by reference. That means it needs to be preceded with an ampersand symbol (&) in the function header.
However, wouldn't it be far simpler to perform a search-and-replace? I think it's worthwhile to learn about regular expressions because there are lots of cases where these are useful. For instance, you can replace all INI_Int lines using a regular expression like so:
Search:
Код:
INI_Int\((.+?),\s?(.+?)\)
Replace:
Код:
$2 = cache_get_field_content_int\(0, $1\)
Re: Converting INI To Mysql in an easier way. -
StrikerZ - 19.08.2017
Quote:
Originally Posted by Vince
It won't do anything because the variable isn't passed by reference. That means it needs to be preceded with an ampersand symbol (&) in the function header.
However, wouldn't it be far simpler to perform a search-and-replace? I think it's worthwhile to learn about regular expressions because there are lots of cases where these are useful. For instance, you can replace all INI_Int lines using a regular expression like so:
Search:
Код:
INI_Int\((.+?),\s?(.+?)\)
Replace:
Код:
$2 = cache_get_field_content_int\(0, $1\)
|
Seems like I got something new to learn, thanks for the information, cheers! Where can I learn more about it? And about that search and replace too.
Re: Converting INI To Mysql in an easier way. -
Vince - 19.08.2017
I always use
regexr.com to test. The menu on the left hand side has full reference about all the different specifiers.
Re: Converting INI To Mysql in an easier way. -
StrikerZ - 19.08.2017
Quote:
Originally Posted by Vince
I always use regexr.com to test. The menu on the left hand side has full reference about all the different specifiers.
|
Thanks!