Mysql help
#6

Those functions no longer exist in R39.

To upgrade from R5 to R39 you will need to re-write all your mysql related code.

I'll give you an example of both loading and saving.
pawn Code:
// R5 loading
mysql_real_escape_string(stringvariable, stringvariable);
format(query, sizeof(query), "SELECT stuff FROM table WHERE something = '%s'", stringvariable);
mysql_query(query);
mysql_store_result();
if(mysql_fetch_field_row(query))
{
      sscanf(query, "p<|>data"....);
}
mysql_free_result();

// R39 loading
mysql_format(connection_handle, query, sizeof(query), "SELECT stuff FROM table WHERE something = '%e'", stringVariable);
new Cache:result = mysql_query(connection_handle, query);
if(cache_get_row_count())
{
     cache_get_field_content(0, "string_column_name", stringVariable);
     printf("String variable:%s", stringVariable); // stringVariable will now hold a value from the column "string_column_name" from row 1.
     printf("int value:%d", cache_get_field_content_int(0, "int_column_name"));
     printf("Float value:%f", cache_get_field_content_float(0, "float_column_name"));
}
cache_delete(result);
Note that cache_get_field_content are NOT the only way to parse the result. Refer to wiki for more info.

pawn Code:
// R5 saving:
mysql_real_escape_string(something, soemthing);
format(query, sizeof(query), "UPDATE table SET int_column = %d, float_column = %f, string_column = '%s' WHERE something = %d", data, something);
mysql_query(query);
format(query, sizeof(query), "INSERT INTO table (int_column, float_column, string_column) VALUES(%d, %f, '%s')");
mysql_query(query);

// R39 saving:
mysql_format(connection_handle, query, sizeof(query), "UPDATE table SET int_column = %d, float_column = %f, string_column = '%e' WHERE something = %d", data, something);
mysql_pquery(connection_handle, query);

mysql_format(connection_handle, query, sizeof(query), "INSERT INTO table (int_column, float_column, string_column) VALUES(%d, %f, '%e')", values...);
mysql_pquery(connection_handle, query);

Check the wiki for mysql_pquery and mysql_tquery documentation.

AS you may have noticed mysql_real_escape_string is replaced by the %e specified in mysql_format.
Reply


Messages In This Thread
Mysql help - by zeth98 - 05.06.2015, 10:57
Re: Mysql help - by Konstantinos - 05.06.2015, 11:01
Re: Mysql help - by dusk - 05.06.2015, 11:01
Re: Mysql help - by zeth98 - 05.06.2015, 11:29
Re: Mysql help - by J0sh... - 05.06.2015, 11:37
Re: Mysql help - by dusk - 05.06.2015, 11:41
Re: Mysql help - by zeth98 - 05.06.2015, 12:12
Re: Mysql help - by nezo2001 - 05.06.2015, 12:33
Re: Mysql help - by zeth98 - 05.06.2015, 12:42
Re: Mysql help - by nezo2001 - 05.06.2015, 12:54

Forum Jump:


Users browsing this thread: 2 Guest(s)