View Single Post
  #5  
Old 07-12-2011, 04:11 PM
Derision
Developer
 
Join Date: Feb 2004
Location: UK
Posts: 1,540
Default

Things to be aware of if you do want to read the database directly:

if database.RunQuery returns false, your DatasetResult will be NULL, i.e. invalid, so all you should do is send some debugging info to the zone log,
free the query if you allocated the memory with MakeAnyLenString, and then bail out, e.g.:
Code:
printf("Query: %s failed with error %s\n", Query, TempErrorMessageBuffer);
fflush(stdout);
safe_delete_array(Query);
return;
Also, if the query is successful, it can still return zero rows, so you need to call mysql_num_rows(DatasetResult) and check it is >0 before calling mysql_fetch_row(),
and/or check mysql_fetch_row() doesn't return NULL when you call it before attempting to process the returned row.
Reply With Quote