How does PAWN deal with NULL returns from a MySQL database?
#8

Included in a_mysql:
Quote:

#define ismysqlnull(%0) (strcmp(%0,"NULL",false)==0)

Example:
pawn Код:
new
    probablyNullField[64]
;
cache_get_row(0, 0, probablyNullField, 1, 64);
if(ismysqlnull(probablyNullField)) {
    print("Oh my, that field was null!");
} else {
    printf("That field wasn't null, and its contents are: %s", probablyNullField);
}
Cache_get_*_int/float probably automagically convert null to 0, so if you have nullable field with distinct reason for null usage, use the former version.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 5 Guest(s)