PatrickGTR / MySQL-Prepared-Statements

Prepared Statement implementation for PAWN MySQL

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add TYPE_USERNAME and TYPE_PLAYERIP

PatrickGTR opened this issue · comments

commented

I have a suggestions about this, since username and IP is a string, why not just do something like this:

stock MySQL_BindUsername(Statement:statement, param, playerid) {
    new playerName[MAX_PLAYER_NAME + 1];
    GetPlayerName(playerid, playerName, sizeof(playerName));

    stmt_bind_value(statement, param, TYPE_STRING, playerIp);
}

stock MySQL_BindIp(Statement:statement, param, playerid) {
    new playerIp[16 + 1];
    GetPlayerIp(playerid, playerIp, sizeof(playerIp));

    stmt_bind_value(statement, param, TYPE_RAW_STRING, playerIp);
}

By doing this, you don't have to create new TYPE for binding the query.

I have a suggestions about this, since username and IP is a string, why not just do something like this:

stock MySQL_BindUsername(Statement:statement, param, playerid) {
    new playerName[MAX_PLAYER_NAME + 1];
    GetPlayerName(playerid, playerName, sizeof(playerName));

    stmt_bind_value(statement, param, TYPE_STRING, playerIp);
}

stock MySQL_BindIp(Statement:statement, param, playerid) {
    new playerIp[16 + 1];
    GetPlayerIp(playerid, playerIp, sizeof(playerIp));

    stmt_bind_value(statement, param, TYPE_RAW_STRING, playerIp);
}

By doing this, you don't have to create new TYPE for binding the query.

Good shout, I don't have time right now but if you can do it, do some tests and make pull request! Thanks.