06.08.2013, 08:37
does anyone know how SQL_UpdateInt works? here is the code:
which then goes to this:
is there anything wrong with these codes?
pawn Code:
stock SQL_UpdateInt(index, field[], value)
{
if ((index >= 0 && index < MAX_UPDATED_QUERIES) && E_QUERY_EXISTS[index])
{
new string[24];
format(string, sizeof(string), "%d", value);
return SQL_UpdateString(index, field, string);
}
return 0;
}
pawn Code:
stock SQL_UpdateString(index, field[], value[])
{
if ((index >= 0 && index < MAX_UPDATED_QUERIES) && E_QUERY_EXISTS[index])
{
new string[128], File:file;
format(string, sizeof(string), "`%s` = '%s', ", field, DB_Escape(value));
if ((strlen(E_QUERY_DATA[index]) + strlen(string)) >= sizeof(E_QUERY_DATA[]))
{
new name[24];
strunpack(name, E_QUERY_NAME[index]);
printf("Warning: Update data buffer trying to exceed %d/%d characters (name: %s, field: %s)", strlen(E_QUERY_DATA[index]), sizeof(E_QUERY_DATA[]), name);
return 0;
}
strins(E_QUERY_DATA[index], string, E_QUERY_POSITION[index]);
file = fopen("fields.ini", io_readwrite);
if (file || !fexist("fields.ini"))
{
new bool:found;
if (!fexist("fields.ini"))
{
found = false;
file = fopen("fields.ini", io_append);
}
else
{
while (fread(file, string, sizeof(string)))
{
if (strcmp(string, field, false, strlen(field)) == 0)
{
found = true;
break;
}
}
}
if (!found)
{
format(string, sizeof(string), "ALTER TABLE `Accounts` ADD COLUMN `%s` DEFAULT 0", field);
db_query(AccountDB, string);
fwrite(file, field);
fwrite(file, "\r\n");
}
fclose(file);
}
return 1;
}
return 0;
}
is there anything wrong with these codes?