[Plugin] [REL] MySQL Plugin (Now on github!)

@PowerPC603: No problem, it's none of my concern. I'm just saying, that some scripts need 5 seconds startup more than 20 seconds (daily gmx, or multiple gamemodes), and you nonetheless should aim at better performance than your competition. Always.
Reply

use cache_get_row_int

you'll see even more speed improvements

PowerPC603

I only use cache_field_content for large tables which i might add values in between often
Reply

I have never understood this
Reply

Quote:
Originally Posted by Misiur
Посмотреть сообщение
@PowerPC603: No problem, it's none of my concern. I'm just saying, that some scripts need 5 seconds startup more than 20 seconds (daily gmx, or multiple gamemodes), and you nonetheless should aim at better performance than your competition. Always.
Performance isn't a problem yet.

I'm only loading 1 speedcam, 23 gas-stations, 7 police-stations and 212 vehicles for now during startup.
As soon as I double-click samp-server.exe, the server is running before I can release my hand from the mouse (if mysql-logging has been disabled).

It now waits until all data has been loaded before moving on (before server is online) with the code I posted above.
Even if it would need 10x more data, it would load in less than a second.

And there will be alot of data to load when the entire GM is finished and everything has been converted to mysql.

Right now, I'm still using files for all gamemode-related data.
Only my filterscript uses mysql for now.



Quote:
Originally Posted by Kar
Посмотреть сообщение
use cache_get_row_int

you'll see even more speed improvements

PowerPC603

I only use cache_field_content for large tables which i might add values in between often
I'm also in the process of adding new columns to some tables, especially the playerdata table.
Adding extra fields could mean some columns will move to present the data in a neater way (most important data in the first columns).

I could use cache_get_row_int at a later date when I'm certain that tables won't change anymore to increase the loading even more.
Right now, the loading is fast enough (I can't see the script waiting yet for data-loading to be completed), it's loaded and running in the blink of an eye.
Reply

About this Mysql_query do you say what i should change to get rid of errors from Mysql_Query i have it in Includes and on plugins everything but gives me error on Mysql_query....
Reply

Erm, could someone provide windows build from latest commit? I don't have boost handy, and really cluttered HDD so can't install it.
Reply

I have big problem, with this plugin. My server shut down after player disconnect(while updating player info with function orm_update). I don't know what to do, please help me. I'am using MySQL R37, operating system is Windows 7.

Code:

Code:
enum pInfo
{
    ORM:ORM_ID,
    ID,
    IP[24],
    Name[MAX_PLAYER_NAME+1],
    Password[101],
    pScore,
    pMoney,
    pSkin,
    pCookies,
    pKills,
    Float:pPosX,
    Float:pPosY,
    Float:pPosZ,
    Float:pPosA,
    bool: Admin,
    bool: VIP,
    Kalba,
    Ispejimai,
    Float: PosX,
    Float: PosY,
    Float: PosZ,
    Float: PosA,
    Registracija[MAX_PLAYERS],
    PaskutinisIP[24],
    Email[101]
}

new MySQL = -1;
new PlayerInfo[MAX_PLAYERS][pInfo];

forward OnPlayerDataLoad(playerid);

public OnGameModeInit()
{
    mysql_log();
    MySQL = mysql_connect(SQL_HOST, SQL_USER, SQL_DB, SQL_PASS);
    return 1;
}

public OnPlayerConnect(playerid)
{

    GetPlayerName(playerid, PlayerInfo[playerid][Name], MAX_PLAYER_NAME);
    new ORM:ormid = PlayerInfo[playerid][ORM_ID] = orm_create("playerdata");

    orm_addvar_int(ormid, PlayerInfo[playerid][ID], "id");
    orm_addvar_string(ormid, PlayerInfo[playerid][Name], MAX_PLAYER_NAME+1, "user");
    orm_addvar_string(ormid, PlayerInfo[playerid][Password], 101, "password");
    orm_addvar_int(ormid, PlayerInfo[playerid][Kalba], "kalba");
    orm_addvar_int(ormid, PlayerInfo[playerid][pScore], "score");
    orm_addvar_int(ormid, PlayerInfo[playerid][pMoney], "money");
    orm_addvar_int(ormid, PlayerInfo[playerid][pSkin], "skin");
    orm_addvar_float(ormid, PlayerInfo[playerid][PosX], "posx");
    orm_addvar_float(ormid, PlayerInfo[playerid][PosY], "posy");
    orm_addvar_float(ormid, PlayerInfo[playerid][PosZ], "posz");
    orm_addvar_float(ormid, PlayerInfo[playerid][PosA], "posa");
    orm_addvar_int(ormid, PlayerInfo[playerid][Registracija], "reg");
    orm_addvar_string(ormid, PlayerInfo[playerid][IP], 24, "IP");
    orm_addvar_string(ormid, PlayerInfo[playerid][PaskutinisIP], 24, "prisijungip");
    orm_addvar_string(ormid, PlayerInfo[playerid][Email], 101, "email");

    orm_setkey(ormid, "user");
    orm_select(ormid, "OnPlayerDataLoad", "d", playerid);
    return 1;
}

public OnPlayerDataLoad(playerid)
{
    switch(orm_errno(PlayerInfo[playerid][ORM_ID]))
    {
        case ERROR_OK:
        {
            // Login
        }
        case ERROR_NO_DATA:
        {
            // Register
        }
    }
    orm_setkey(PlayerInfo[playerid][ORM_ID], "ID");
    printf("» Ћaidėjas %s prisijungė!", GetName(playerid));
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    if(PlayerInfo[playerid][ID] != 0) 
    {
        GetPlayerPos(playerid,PlayerInfo[playerid][PosX],PlayerInfo[playerid][PosY],PlayerInfo[playerid][PosZ]);
        GetPlayerFacingAngle(playerid,PlayerInfo[playerid][PosA]);
        orm_update(PlayerInfo[playerid][ORM_ID]);
    }
    orm_destroy(PlayerInfo[playerid][ORM_ID]);
    return 1;
}
mysql_log.txt info:

Code:
[13:12:31] [DEBUG] mysql_connect - host: "localhost", user: "root", database: "freeroam", password: "****", port: 3306, autoreconnect: true, pool_size: 2
[13:12:31] [DEBUG] CMySQLHandle::Create - creating new connection..
[13:12:31] [DEBUG] CMySQLHandle::CMySQLHandle - constructor called
[13:12:31] [DEBUG] CMySQLHandle::Create - connection created (id: 1)
[13:12:31] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[13:12:31] [DEBUG] CMySQLConnection::Connect - connection was successful
[13:12:31] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
[13:12:31] [DEBUG] mysql_errno - connection: 1
[13:12:31] [DEBUG] mysql_format - connection: 1, len: 2000, format: "UPDATE serveris SET sname = 'FreeRoam', sip = '127.0.0.1', sport = '7777', sgmv = 'SA-FR 0.0.1 Beta', s..."
[13:12:31] [DEBUG] mysql_tquery - connection: 1, query: "UPDATE serveris SET sname = 'FreeRoam', si", callback: "(null)", format: "(null)"
[13:12:31] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[13:12:31] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[13:12:31] [DEBUG] CMySQLConnection::Connect - establishing connection to database...
[13:12:31] [DEBUG] CMySQLConnection::Connect - connection was successful
[13:12:31] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
[13:12:31] [DEBUG] CMySQLConnection::Connect - connection was successful
[13:12:31] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
[13:12:31] [DEBUG] CMySQLConnection::Connect - connection was successful
[13:12:31] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
[13:12:31] [DEBUG] CMySQLQuery::Execute[] - starting query execution
[13:12:31] [DEBUG] CMySQLQuery::Execute[] - query was successfully executed within 29.807 milliseconds
[13:12:31] [DEBUG] CMySQLQuery::Execute[] - no callback specified, skipping result saving
[13:13:13] [DEBUG] orm_create - table: "playerdata", connectionHandle: 1
[13:13:13] [DEBUG] COrm::Create - creating new orm object..
[13:13:13] [DEBUG] COrm::Create - orm object created (id: 1)
[13:13:13] [DEBUG] orm_addvar - orm_id: 1, var: 03879C34, datatype: 0, varname: "id", var_maxlen: 1
[13:13:13] [DEBUG] orm_addvar - orm_id: 1, var: 03879C98, datatype: 2, varname: "user", var_maxlen: 25
[13:13:13] [DEBUG] orm_addvar - orm_id: 1, var: 03879CFC, datatype: 2, varname: "password", var_maxlen: 101
[13:13:13] [DEBUG] orm_addvar - orm_id: 1, var: 03879EBC, datatype: 0, varname: "kalba", var_maxlen: 1
[13:13:13] [DEBUG] orm_addvar - orm_id: 1, var: 03879E90, datatype: 0, varname: "score", var_maxlen: 1
[13:13:13] [DEBUG] orm_addvar - orm_id: 1, var: 03879E94, datatype: 0, varname: "money", var_maxlen: 1
[13:13:13] [DEBUG] orm_addvar - orm_id: 1, var: 03879E98, datatype: 0, varname: "skin", var_maxlen: 1
[13:13:13] [DEBUG] orm_addvar - orm_id: 1, var: 03879EC4, datatype: 1, varname: "posx", var_maxlen: 1
[13:13:13] [DEBUG] orm_addvar - orm_id: 1, var: 03879EC8, datatype: 1, varname: "posy", var_maxlen: 1
[13:13:13] [DEBUG] orm_addvar - orm_id: 1, var: 03879ECC, datatype: 1, varname: "posz", var_maxlen: 1
[13:13:13] [DEBUG] orm_addvar - orm_id: 1, var: 03879ED0, datatype: 1, varname: "posa", var_maxlen: 1
[13:13:13] [DEBUG] orm_addvar - orm_id: 1, var: 03879ED4, datatype: 0, varname: "reg", var_maxlen: 1
[13:13:13] [DEBUG] orm_addvar - orm_id: 1, var: 03879C38, datatype: 2, varname: "IP", var_maxlen: 24
[13:13:13] [DEBUG] orm_addvar - orm_id: 1, var: 0387A0B8, datatype: 2, varname: "prisijungip", var_maxlen: 24
[13:13:13] [DEBUG] orm_addvar - orm_id: 1, var: 0387A118, datatype: 2, varname: "email", var_maxlen: 101
[13:13:13] [DEBUG] orm_setkey - orm_id: 1, varname: "user"
[13:13:13] [DEBUG] orm_select - orm_id: 1, callback: "OnPlayerDataLoad", format: "d"
[13:13:13] [DEBUG] CMySQLQuery::Execute[OnPlayerDataLoad] - starting query execution
[13:13:13] [DEBUG] CMySQLQuery::Execute[OnPlayerDataLoad] - query was successfully executed within 0.545 milliseconds
[13:13:13] [DEBUG] CMySQLResult::CMySQLResult() - constructor called
[13:13:13] [DEBUG] CMySQLResult::GetRowData - row: '0', field: '0', data: "90"
[13:13:13] [DEBUG] CMySQLResult::GetRowData - row: '0', field: '1', data: "1845c5654ddfca52d6d38181a93ade47"
[13:13:13] [DEBUG] CMySQLResult::GetRowData - row: '0', field: '2', data: "0"
[13:13:13] [DEBUG] CMySQLResult::GetRowData - row: '0', field: '3', data: "0"
[13:13:13] [DEBUG] CMySQLResult::GetRowData - row: '0', field: '4', data: "0"
[13:13:13] [DEBUG] CMySQLResult::GetRowData - row: '0', field: '5', data: "0"
[13:13:13] [DEBUG] CMySQLResult::GetRowData - row: '0', field: '6', data: "0"
[13:13:13] [DEBUG] CMySQLResult::GetRowData - row: '0', field: '7', data: "0"
[13:13:13] [DEBUG] CMySQLResult::GetRowData - row: '0', field: '8', data: "0"
[13:13:13] [DEBUG] CMySQLResult::GetRowData - row: '0', field: '9', data: "0"
[13:13:13] [DEBUG] CMySQLResult::GetRowData - row: '0', field: '10', data: "4"
[13:13:13] [DEBUG] CMySQLResult::GetRowData - row: '0', field: '11', data: ""
[13:13:13] [DEBUG] CMySQLResult::GetRowData - row: '0', field: '12', data: ""
[13:13:13] [DEBUG] CMySQLResult::GetRowData - row: '0', field: '13', data: "test@gmail.com"
[13:13:13] [DEBUG] Calling callback "OnPlayerDataLoad"..
[13:13:13] [DEBUG] orm_errno - orm_id: 1
[13:13:13] [DEBUG] orm_setkey - orm_id: 1, varname: "ID"
[13:13:13] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
[13:13:25] [DEBUG] mysql_escape_string - source: "123456789", connection: 1, max_len: 101
[13:13:30] [DEBUG] orm_update - orm_id: 1
crashinfo:

Code:
 Loaded Modules:

samp-server.exe    A: 0x00400000 - 0x004F5000    (C:\Users\Auksinis\Desktop\MySQL\samp-server.exe)
ntdll.dll    A: 0x77650000 - 0x7778C000    (C:\Windows\SYSTEM32\ntdll.dll)
kernel32.dll    A: 0x75FE0000 - 0x760B4000    (C:\Windows\system32\kernel32.dll)
KERNELBASE.dll    A: 0x75930000 - 0x7597B000    (C:\Windows\system32\KERNELBASE.dll)
SHELL32.dll    A: 0x76240000 - 0x76E8A000    (C:\Windows\system32\SHELL32.dll)
msvcrt.dll    A: 0x775A0000 - 0x7764C000    (C:\Windows\system32\msvcrt.dll)
SHLWAPI.dll    A: 0x77540000 - 0x77597000    (C:\Windows\system32\SHLWAPI.dll)
GDI32.dll    A: 0x771C0000 - 0x7720E000    (C:\Windows\system32\GDI32.dll)
USER32.dll    A: 0x770F0000 - 0x771B9000    (C:\Windows\system32\USER32.dll)
LPK.dll    A: 0x76230000 - 0x7623A000    (C:\Windows\system32\LPK.dll)
USP10.dll    A: 0x76190000 - 0x7622D000    (C:\Windows\system32\USP10.dll)
WSOCK32.dll    A: 0x6D060000 - 0x6D067000    (C:\Windows\system32\WSOCK32.dll)
WS2_32.dll    A: 0x770B0000 - 0x770E5000    (C:\Windows\system32\WS2_32.dll)
RPCRT4.dll    A: 0x777D0000 - 0x77872000    (C:\Windows\system32\RPCRT4.dll)
NSI.dll    A: 0x759C0000 - 0x759C6000    (C:\Windows\system32\NSI.dll)
WINMM.dll    A: 0x73040000 - 0x73072000    (C:\Windows\system32\WINMM.dll)
IMM32.DLL    A: 0x777B0000 - 0x777CF000    (C:\Windows\system32\IMM32.DLL)
MSCTF.dll    A: 0x760C0000 - 0x7618C000    (C:\Windows\system32\MSCTF.dll)
mysql.DLL    A: 0x67450000 - 0x6748F000    (C:\Users\Auksinis\Desktop\MySQL\plugins\mysql.DLL)
LIBMYSQL.dll    A: 0x10000000 - 0x1023E000    (C:\Users\Auksinis\Desktop\MySQL\LIBMYSQL.dll)
ADVAPI32.dll    A: 0x774A0000 - 0x77540000    (C:\Windows\system32\ADVAPI32.dll)
sechost.dll    A: 0x77790000 - 0x777A9000    (C:\Windows\SYSTEM32\sechost.dll)
MSVCP110.dll    A: 0x673C0000 - 0x67445000    (C:\Windows\system32\MSVCP110.dll)
MSVCR110.dll    A: 0x672E0000 - 0x673B6000    (C:\Windows\system32\MSVCR110.dll)
NLAapi.dll    A: 0x73B70000 - 0x73B80000    (C:\Windows\system32\NLAapi.dll)
napinsp.dll    A: 0x717C0000 - 0x717D0000    (C:\Windows\system32\napinsp.dll)
pnrpnsp.dll    A: 0x717A0000 - 0x717B2000    (C:\Windows\system32\pnrpnsp.dll)
mswsock.dll    A: 0x750A0000 - 0x750DC000    (C:\Windows\System32\mswsock.dll)
DNSAPI.dll    A: 0x74F60000 - 0x74FA4000    (C:\Windows\system32\DNSAPI.dll)
winrnr.dll    A: 0x71790000 - 0x71798000    (C:\Windows\System32\winrnr.dll)
rasadhlp.dll    A: 0x70590000 - 0x70596000    (C:\Windows\system32\rasadhlp.dll)
sscanf.DLL    A: 0x01220000 - 0x0122B000    (C:\Users\Auksinis\Desktop\MySQL\plugins\sscanf.DLL)
MSVCR90.dll    A: 0x6EE50000 - 0x6EEF3000    (C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.6161_none_50934f2ebcb7eb57\MSVCR90.dll)
streamer.DLL    A: 0x69640000 - 0x6966D000    (C:\Users\Auksinis\Desktop\MySQL\plugins\streamer.DLL)
MSVCP90.dll    A: 0x6B640000 - 0x6B6CE000    (C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.6161_none_50934f2ebcb7eb57\MSVCP90.dll)
dbghelp.dll    A: 0x64690000 - 0x6477B000    (C:\Windows\system32\dbghelp.dll)
MSVCP100.dll    A: 0x5BBB0000 - 0x5BC19000    (C:\Windows\system32\MSVCP100.dll)
MSVCR100.dll    A: 0x71B60000 - 0x71C1F000    (C:\Windows\system32\MSVCR100.dll)
wshtcpip.dll    A: 0x74B30000 - 0x74B35000    (C:\Windows\System32\wshtcpip.dll)
IPHLPAPI.DLL    A: 0x73790000 - 0x737AC000    (C:\Windows\system32\IPHLPAPI.DLL)
WINNSI.DLL    A: 0x73780000 - 0x73787000    (C:\Windows\system32\WINNSI.DLL)
CRYPTBASE.dll    A: 0x755E0000 - 0x755EC000    (C:\Windows\system32\CRYPTBASE.dll)
uxtheme.dll    A: 0x742C0000 - 0x74300000    (C:\Windows\system32\uxtheme.dll)
PROPSYS.dll    A: 0x74400000 - 0x744F5000    (C:\Windows\system32\PROPSYS.dll)
OLEAUT32.dll    A: 0x75E20000 - 0x75EAF000    (C:\Windows\system32\OLEAUT32.dll)
comctl32.dll    A: 0x74540000 - 0x746DE000    (C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.7601.17514_none_41e6975e2bd6f2b2\comctl32.dll)
apphelp.dll    A: 0x75590000 - 0x755DC000    (C:\Windows\system32\apphelp.dll)
CLBCatQ.DLL    A: 0x759D0000 - 0x75A53000    (C:\Windows\system32\CLBCatQ.DLL)
api-ms-win-downlevel-advapi32-l1-1-0.dll    A: 0x758B0000 - 0x758B5000    (C:\Windows\system32\api-ms-win-downlevel-advapi32-l1-1-0.dll)
api-ms-win-downlevel-shlwapi-l1-1-0.dll    A: 0x756E0000 - 0x756E4000    (C:\Windows\system32\api-ms-win-downlevel-shlwapi-l1-1-0.dll)
SETUPAPI.dll    A: 0x77270000 - 0x7740D000    (C:\Windows\system32\SETUPAPI.dll)
CFGMGR32.dll    A: 0x758F0000 - 0x75917000    (C:\Windows\system32\CFGMGR32.dll)
DEVOBJ.dll    A: 0x758C0000 - 0x758D2000    (C:\Windows\system32\DEVOBJ.dll)
ntmarta.dll    A: 0x74BB0000 - 0x74BD1000    (C:\Windows\system32\ntmarta.dll)
WLDAP32.dll    A: 0x77210000 - 0x77255000    (C:\Windows\system32\WLDAP32.dll)
Secur32.dll    A: 0x75550000 - 0x75558000    (C:\Windows\system32\Secur32.dll)
SSPICLI.DLL    A: 0x75570000 - 0x7558B000    (C:\Windows\system32\SSPICLI.DLL)
api-ms-win-downlevel-advapi32-l2-1-0.dll    A: 0x707C0000 - 0x707C4000    (C:\Windows\system32\api-ms-win-downlevel-advapi32-l2-1-0.dll)
Crash Detect info:

Code:
[12:43:28] [debug] Server crashed while executing SA-FR.amx
[12:43:28] [debug] AMX backtrace:
[12:43:28] [debug] #0 native orm_update () [673daec0] from mysql.DLL
[12:43:28] [debug] #1 00046bac in ?? (0x00000000) from SA-FR.amx
[12:43:28] [debug] #2 00016004 in ?? (0x00000000, 0x00000001) from SA-FR.amx
[12:43:28] [debug] #3 00005fd0 in public Itter_OnPlayerDisconnect (0x00000000, 0x00000001) from SA-FR.amx
[12:43:28] [debug] #4 00001d14 in public OnPlayerDisconnect (0x00000000, 0x00000001) from SA-FR.amx
[12:43:28] [debug] Native backtrace:
[12:43:28] [debug] #0 673d17f5 in ?? () from plugins\mysql.DLL
[12:43:28] [debug] #1 673dafdf in ?? () from plugins\mysql.DLL
[12:43:28] [debug] #2 004010b6 in ?? () from samp-server.exe
[12:43:28] [debug] #3 673158ca in ?? () from plugins\crashdetect.DLL
[12:43:28] [debug] #4 6731774f in ?? () from plugins\crashdetect.DLL
[12:43:28] [debug] #5 67310834 in ?? () from plugins\crashdetect.DLL
[12:43:28] [debug] #6 6731591a in ?? () from plugins\crashdetect.DLL
[12:43:28] [debug] #7 0046cc7b in ?? () from samp-server.exe
[12:43:28] [debug] #8 0046600e in ?? () from samp-server.exe
[12:43:28] [debug] #9 673c15e3 in ?? () from plugins\mysql.DLL
[12:43:28] [debug] #10 004877cb in ?? () from samp-server.exe
[12:43:28] [debug] #11 5c8b01f8 in ?? () from samp-server.exe
[12:43:28] [debug] #12 61750824 in ?? () from samp-server.exe
Reply

Quote:
Originally Posted by Misiur
Посмотреть сообщение
Erm, could someone provide windows build from latest commit? I don't have boost handy, and really cluttered HDD so can't install it.
Here are the Windows binaries for this as the latest commit.

Quote:
Originally Posted by Imagination
Посмотреть сообщение
I have big problem, with this plugin. My server shut down after player disconnect(while updating player info with function orm_update). I don't know what to do, please help me. I'am using MySQL R37, operating system is Windows 7.
You made a scripting mistake in that line:
Код:
orm_setkey(PlayerInfo[playerid][ORM_ID], "ID");
You have to write "id" instead of "ID" since MySQL (and thus the ORM system) is case-sensitive.

However, a crash is still a crash. I've fixed that crash by improving the error handling within the ORM system.
Reply

R35 introduced parallel queries. What is that? What are the advantages and disadvantages of it? When should I use it?
Reply

Quote:
Originally Posted by dusk
Посмотреть сообщение
R35 introduced parallel queries. What is that? What are the advantages and disadvantages of it? When should I use it?
https://sampwiki.blast.hk/wiki/MySQL/R33#mysql_pquery
Quote:
Originally Posted by wiki
The difference between this native and mysql_tquery() is, that this type of query uses multi-threading, thus it's faster depending on how many connections are used. The number of connections can be specified in mysql_connect() through the pool_size parameter. Each connection resembles a thread.
advantages:
- faster (depending on the hardware specs of the machine the plugin is running on)

disadvantages:
- doesn't support transactions
- [R37+] queries aren't executed in the same order they were sent
Reply

Thanks for the information. What transactions are we talking about?


Different question. I want to send one query in another ones function. If I do that I get this warning:
pawn Код:
[WARNING] cache_get_row_count - no active cache
pawn Код:
public OnDMZoneLoad()
{
    new query[50];
    for(new i; i < cache_get_row_count(); i++)
    {
        format(query,sizeof(query),"SELECT * FROM dm_area_points WHERE AreaId = %d",cache_get_row_int(i,0));
        new Cache:r = mysql_query(DbHandle,query);
        if(cache_get_row_count())
        {
            //something
        }
        cache_delete(r);
    }
    return 1;
}
I would make the second query threaded, but I will need data from the first one...

This has been on my mind for quite some time.. Or is my table design flawed?
Reply

Does it give the warning even if you use cache_num_rows instead of cache_get_row_count?
Reply

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Does it give the warning even if you use cache_num_rows instead of cache_get_row_count?
Although I didn't try it, I'm sure there's not difference. cache_num_rows is just a define.
Reply

Quote:
Originally Posted by dusk
Посмотреть сообщение
Thanks for the information. What transactions are we talking about?


Different question. I want to send one query in another ones function. If I do that I get this warning:
pawn Код:
[WARNING] cache_get_row_count - no active cache
[...]
I would make the second query threaded, but I will need data from the first one...

This has been on my mind for quite some time.. Or is my table design flawed?
The first active cache is the cache from the threaded query. You are overwriting this cache by sending an unthreaded query. Then you delete the cache from the unthreaded query, thus there is no active cache anymore.
The solution is to save the cache from the threaded query and always re-set it as active. However, this isn't a very good solution, I think your whole code can be improved with a JOIN LEFT query.

pawn Код:
public OnDMZoneLoad()
{
    new query[50];
    new Cache:thread_cache = cache_save();
   
    for(new i; i < cache_get_row_count(); i++)
    {
        format(query,sizeof(query),"SELECT * FROM dm_area_points WHERE AreaId = %d",cache_get_row_int(i,0));
        new Cache:r = mysql_query(DbHandle,query);
        if(cache_get_row_count())
        {
            //something
        }
        cache_delete(r);
        cache_set_active(thread_cache);
    }
   
    cache_delete(thread_cache);
    return 1;
}
And yes, 'cache_num_rows' is just a #define and is the same as 'cache_get_row_count'.
Reply

Quote:
Originally Posted by maddinat0r
Посмотреть сообщение
The first active cache is the cache from the threaded query. You are overwriting this cache by sending an unthreaded query. Then you delete the cache from the unthreaded query, thus there is no active cache anymore.
The solution is to save the cache from the threaded query and always re-set it as active. However, this isn't a very good solution, I think your whole code can be improved with a JOIN LEFT query.

pawn Код:
public OnDMZoneLoad()
{
    new query[50];
    new Cache:thread_cache = cache_save();
   
    for(new i; i < cache_get_row_count(); i++)
    {
        format(query,sizeof(query),"SELECT * FROM dm_area_points WHERE AreaId = %d",cache_get_row_int(i,0));
        new Cache:r = mysql_query(DbHandle,query);
        if(cache_get_row_count())
        {
            //something
        }
        cache_delete(r);
        cache_set_active(thread_cache);
    }
   
    cache_delete(thread_cache);
    return 1;
}
And yes, 'cache_num_rows' is just a #define and is the same as 'cache_get_row_count'.
Thanks again, I ******d that "LEFT JOIN" thingy and it turned out to be as interesting as useful
Reply

Ok I scripted a script that I want to change to Linux, works fine on windows doesn't work on linux cause of the plugins, there are errors with MySQL plugins.
Код:
[23:18:49]    Error: Function not registered: 'mysql_function_query'
[23:18:49]    Error: Function not registered: 'mysql_debug'
[23:18:49]    Error: Function not registered: 'mysql_ping'
[23:18:49]    Error: Function not registered: 'mysql_real_escape_string'
[23:18:49]    Error: Function not registered: 'mysql_affected_rows'
Which MySQL.so and libmysql.so should I use?
Reply

There is no "libmysql.so". You have to use R7 or R8.
Reply

Still the same errors

Код:
 Failed (libmysqlclient_r.so.16: cannot open shared object file: No such file or directory)
Reply

Quote:
Originally Posted by KevinPRINCE
Посмотреть сообщение
Still the same errors
Quote:
Originally Posted by KevinPRINCE
Посмотреть сообщение
[...]
Код:
[23:18:49]    Error: Function not registered: 'mysql_function_query'
[23:18:49]    Error: Function not registered: 'mysql_debug'
[23:18:49]    Error: Function not registered: 'mysql_ping'
[23:18:49]    Error: Function not registered: 'mysql_real_escape_string'
[23:18:49]    Error: Function not registered: 'mysql_affected_rows'
[...]
Quote:
Originally Posted by KevinPRINCE
Посмотреть сообщение
Код:
 Failed (libmysqlclient_r.so.16: cannot open shared object file: No such file or directory)
Yeah, they sure are the same.
Use the mysql_static.so.
Reply

Quote:

Yeah, they sure are the same.

I said they are the same cause cause of this
Код:
[09:48:10]   Failed (libmysqlclient_r.so.16: cannot open shared object file: No such file or directory)
[09:48:10]  Loading plugin: streamer.so
[09:48:10] 

*** Streamer Plugin v2.6.1 by Incognito loaded ***

[09:48:10]   Loaded.
[09:48:10]  Loading plugin: sscanf.so
[09:48:10] 

[09:48:10]  ===============================

[09:48:10]       sscanf plugin loaded.     

[09:48:10]          Version:  2.8.1        

[09:48:10]    © 2012 Alex "******" Cole  

[09:48:10]  ===============================

[09:48:10]   Loaded.
[09:48:10]  Loading plugin: Whirlpool.so
[09:48:10]  
[09:48:10]  ==================
[09:48:10]  
[09:48:10]   Whirlpool loaded
[09:48:10]  
[09:48:10]  ==================
[09:48:10]  
[09:48:10]   Loaded.
[09:48:10]  Loading plugin: nativechecker.so
[09:48:10]   Loaded.
[09:48:10]  Loaded 4 plugins.

[09:48:10] 
[09:48:10] Filterscripts
[09:48:10] ---------------
[09:48:10]   Loaded 0 filterscripts.

[09:48:10]    Error: Function not registered: 'cache_get_data'
[09:48:10]    Error: Function not registered: 'cache_get_field_content'
[09:48:10]    Error: Function not registered: 'mysql_function_query'
[09:48:10]    Error: Function not registered: 'mysql_debug'
[09:48:10]    Error: Function not registered: 'mysql_connect'
[09:48:10]    Error: Function not registered: 'mysql_ping'
[09:48:10]    Error: Function not registered: 'mysql_close'
[09:48:10]    Error: Function not registered: 'mysql_real_escape_string'
[09:48:10]    Error: Function not registered: 'cache_get_row'
[09:48:10]    Error: Function not registered: 'mysql_affected_rows'
Anyways I will try the static, will contact you if it doesn't work.
Reply


Forum Jump:


Users browsing this thread: 10 Guest(s)