MySQL plugin R39-3 // cache, bad loading
#1

This is the stock im using on gamemodeinit();

PHP код:
stock LoadFirms()
{
    new 
string[61], string2[61];
    
printf("LOADING");
    
mysql_format(dbHandle,g_szBuffer500,"SELECT * FROM `firms`");
    new 
Cache:result=mysql_query(dbHandle,g_szBuffer);
    
printf("%d\n",cache_get_row_count());
    for(new 
icache_get_row_count(); i++){
        
firma][ idas ] = cache_get_field_content_int(i"ID");
        
cache_get_field_content(i,"name"stringdbHandle60);
        
format(firma][ name ], 59,"%s"string);
        
printf("%s  1\n"string);
        
cache_get_field_content(i,"place"string2dbHandle60);
        
format(firma][ place ], 59,"%s"string2);
        
printf("%s  2\n"string2);
        
firma][ pos ][ ] = cache_get_field_content_float(i,"x");
        
firma][ pos ][ ] = cache_get_field_content_float(i,"y");
        
firma][ pos ][ ] = cache_get_field_content_float(i,"z");
        
firma][ Owned ] = cache_get_field_content_int(i"owned");
        
printf("%i OWNED\n"firma][ Owned ]);
        
cache_get_field_content(i,"owner",firma][Owner], dbHandle25);
        
printf("%s OWNER\n"firma][Owner]);
        
firma][ price ] = cache_get_field_content_int(i"price");
        
printf("%i KAINA\n"firma][ price ]);
        
firma][ workers ][ ] = cache_get_field_content_int(i"workers");
        
printf("%i DARBUOTOJAI\n"firma][ workers ][ ]);
        
firma][ workers ][ ] = cache_get_field_content_int(i"workerslimit");
        
printf("%i DARBUOTOJAI 1\n"firma][ workers ][ ]);
        
firma][ workers ][ ] = cache_get_field_content_int(i"workersAccepting");
        
printf("%i ISIDARBINIMAS\n"firma][ workers ][ ]);
        
firma][ profit ] = cache_get_field_content_int(i"profit");
        
printf("%i PROFIT\n"firma][ profit ]);
        
firma][ contractTime ] = cache_get_field_content_int(i"contract");
        
printf("%i KONTRAKT\n"firma][ contractTime ]);
        if(
firma][ Owned ])
        {
            new 
priemimas[70];
            switch(
firma][ workers ][ ]){
                case 
0format(priemimassizeof(priemimas), "{69B86E}įsidarbinimas leidћiamas{B89769}");
                case 
1format(priemimassizeof(priemimas), "{B87669}įsidarbinimas draudћiamas{B89769}");
            }
            
formatg_szBuffer600,"{B89769}%s{ffffff} firma,\n \n{B89769}%s{ffffff}\n{B89769}%s{ffffff} firmos savininkas\n{B89769}%i (  ){ffffff} laisvos darbo vietos\n{B89769}%s{ffffff} darbo kontrakto laikas",firma][ name ],firma][ place ],firma][Owner],(firma][ workers ][ ]-firma][ workers ][ ]), priemimasConvertSeconds(firma][ contractTime ]));
            
firma][ firmLabel ] = Create3DTextLabelg_szBuffer0xFFFFFFFfirma][ pos ][ ],firma][ pos ][ ],firma][ pos ][ ], 300)    ;
            
firma][ pickup ] = CreateDynamicPickup12751firma][ pos ][ ],firma][ pos ][ ],firma][ pos ][ ]);
        }
        else
        {
            
formatg_szBuffer600,"{B89769}%s{ffffff} firma,\n \n{B89769}%s{ffffff}\n{B89769}%i "EURAS"{ffffff} firmos kaina\n \nNorėdami pirkti firmą spauskite {B89769}ENTER",firma][ name ],firma][ place ],firma][ price ]);
            
firma][ firmLabel ] = Create3DTextLabelg_szBuffer0xFFFFFFFfirma][ pos ][ ],firma][ pos ][ ],firma][ pos ][ ], 300)    ;
            
firma][ pickup ] = CreateDynamicPickup12751firma][ pos ][ ],firma][ pos ][ ],firma][ pos ][ ]);
        }
        
printf("%s %s uћkrauta\n"firma][ name ],firma][ place ]);
        
printf("X : %0.3f Y : %0.3f Z : %0.3f uћkrauta\n"firma][ pos ][ ],firma][ pos ][ ],firma][ pos ][ ]);
        
cache_delete(result);
    }

This code fails to load some things, the connection some how drops down or something happens.

The logs of mysql and server prints:
PHP код:
[21:30:32] [DEBUGCMySQLQuery::Execute query was successfully executed within 0.458 milliseconds
[21:30:32] [DEBUGCMySQLResult::CMySQLResult() - constructor called
[21:30:32] [DEBUGCMySQLHandle::SaveActiveResult cache saved (id1)
[
21:30:32] [DEBUGcache_get_row_count connection1
[21:30:32] [DEBUGcache_get_row_count connection1
[21:30:32] [DEBUGcache_get_field_content_int row0field_name"ID"connection1
[21:30:32] [DEBUGCMySQLResult::GetRowDataByName row'0'field"ID"data"0"
[21:30:32] [DEBUGcache_get_field_content row0field_name"name"connection1max_len60
[21:30:32] [DEBUGCMySQLResult::GetRowDataByName row'0'field"name"data"Blueberry transport shipping"
[21:30:32] [DEBUGcache_get_field_content row0field_name"place"connection1max_len60
[21:30:32] [DEBUGCMySQLResult::GetRowDataByName row'0'field"place"data"Blueberry village"
[21:30:32] [DEBUGcache_get_field_content_float row0field_name"x"connection1
[21:30:32] [DEBUGCMySQLResult::GetRowDataByName row'0'field"x"data"-49.8717"
[21:30:32] [DEBUGCMySQLConnection::Connect establishing connection to database...
 
1
[21:30:32] [DEBUGCMySQLResult::GetRowDataByName row'0'field"y"data"-269.363"
[21:30:32] [DEBUGcache_get_field_content_float row0field_name"z"connection1
[21:30:32] [DEBUGCMySQLResult::GetRowDataByName row'0'field"z"data"6.6332"
[21:30:32] [DEBUGCMySQLConnection::Connect establishing connection to database...
n1
[21:30:32] [DEBUGCMySQLConnection::Connect establishing connection to database...
[
21:30:32] [DEBUGCMySQLResult::GetRowDataByName row'0'field"owned"data"0"
[21:30:32] [DEBUGcache_get_field_content row0field_name"village"connection1max_len25
[21:30:32] [WARNINGCMySQLResult::GetRowDataByName field not found ("village")
[
21:30:32] [DEBUGcache_get_field_content_int row0field_name"price"connection1
[21:30:32] [DEBUGCMySQLResult::GetRowDataByName row'0'field"price"data"5000"
[21:30:32] [DEBUGcache_get_field_content_int row0field_name"workers"connection1
[21:30:32] [DEBUGCMySQLResult::GetRowDataByName row'0'field"workers"data"0"
[21:30:32] [DEBUGcache_get_field_content_int row0field_name"ULL"connection1
[21:30:32] [WARNINGCMySQLResult::GetRowDataByName field not found ("ULL")
[
21:30:32] [ERRORcache_get_field_content_int invalid datatype
[21:30:32] [DEBUGcache_get_field_content_int row0field_name"workersAccepting"connection1
[21:30:32] [DEBUGCMySQLResult::GetRowDataByName row'0'field"workersAccepting"data"0"
[21:30:32] [DEBUGcache_get_field_content_int row0field_name"profit"connection1
[21:30:32] [DEBUGCMySQLResult::GetRowDataByName row'0'field"profit"data"0"
[21:30:32] [DEBUGcache_get_field_content_int row0field_name"contract"connection1
[21:30:32] [DEBUGCMySQLResult::GetRowDataByName row'0'field"contract"data"36000"
[21:30:32] [DEBUGCMySQLConnection::Connect connection was successful
[21:30:32] [DEBUGCMySQLConnection::Connect auto-reconnect has been enabled
[21:30:32] [DEBUGCMySQLConnection::Connect connection was successful
[21:30:32] [DEBUGCMySQLConnection::Connect auto-reconnect has been enabled
[21:30:32] [DEBUGCMySQLConnection::Connect connection was successful
[21:30:32] [DEBUGCMySQLConnection::Connect auto-reconnect has been enabled
[21:30:32] [DEBUGcache_delete cache_id1connection1
[21:30:32] [DEBUGCMySQLResult::~CMySQLResult() - deconstructor called
[21:30:32] [DEBUGCMySQLHandle::DeleteSavedResult result deleted
[21:30:32] [DEBUGcache_get_row_count connection1
[21:30:32] [WARNINGcache_get_row_count no active cache
[21:30:32LOADING
[21:30:321
[21:30:32ing
[21:30:32Blueberry village  2
[21:30:32Blueberry village
[21:30:32e
[21:30:325000 KAINA
[21:30:320 DARBUOTŸw-I
[21:30:320 DARBUOTOˆ
[21:30:320 ISIDARBINIMAS
[21:30:320 PROFIT
[21:30:3236000 KONTRAKT
[21:30:32Blueberry transport shipping Blueberry village uћkrauta
[21:30:32: -49.871 Y : -269.363 Z 6.633 uћkrauta
[21:30:32
[
21:31:19] [DEBUGmysql_connect host"localhost"user"root"database"truckmania"password"****"port3306autoreconnecttruepool_size2
[21:31:19] [DEBUGCMySQLHandle::Create creating new connection..
[
21:31:19] [DEBUGCMySQLHandle::CMySQLHandle constructor called
[21:31:19] [DEBUGCMySQLHandle::Create connection created (id1)
[
21:31:19] [DEBUGCMySQLConnection::Connect establishing connection to database...
[
21:31:19] [DEBUGCMySQLConnection::Connect connection was successful
[21:31:19] [DEBUGCMySQLConnection::Connect auto-reconnect has been enabled
[21:31:19] [DEBUGmysql_format connection1len500format"SELECT * FROM `firms`"
[21:31:19] [DEBUGmysql_query connection1query"SELECT * FROM `firms`"use_cachetrue
[21:31:19] [DEBUGCMySQLQuery::Execute starting query execution
[21:31:19] [DEBUGCMySQLQuery::Execute query was successfully executed within 0.438 milliseconds
[21:31:19] [DEBUGCMySQLResult::CMySQLResult() - constructor called
[21:31:19] [DEBUGCMySQLHandle::SaveActiveResult cache saved (id1)
[
21:31:19] [DEBUGcache_get_row_count connection1
[21:31:19] [DEBUGcache_get_row_count connection1
[21:31:19] [DEBUGcache_get_field_content_int row0field_name"ID"connection1
[21:31:19] [DEBUGCMySQLResult::GetRowDataByName row'0'field"ID"data"0"
[21:31:19] [DEBUGcache_get_field_content row0field_name"name"connection1max_len60
[21:31:19] [DEBUGCMySQLResult::GetRowDataByName row'0'field"name"data"Blueberry transport shipping"
[21:31:19] [DEBUGcache_get_field_content row0field_name"place"connection1max_len60
[21:31:19] [DEBUGCMySQLResult::GetRowDataByName row'0'field"place"data"Blueberry village"
[21:31:19] [DEBUGcache_get_field_content_float row0field_name"x"connection1
[21:31:19] [DEBUGCMySQLConnection::Connect establishing connection to database...
[
21:31:19] [DEBUGCMySQLConnection::Connect establishing connection to database...
[
21:31:19] [DEBUGCMySQLResult::GetRowDataByName row'0'field"x"data"-49.8717"
[21:31:19] [DEBUGcache_get_field_content_float row0field_name"y"connection1
[21:31:19] [DEBUGCMySQLResult::GetRowDataByName row'0'field"y"data"-269.363"
[21:31:19] [DEBUGcache_get_field_content_float row0field_name"z"connection1
[21:31:19] [DEBUGCMySQLResult::GetRowDataByName row'0'field"z"data"6.6332"
[21:31:19] [DEBUGcache_get_field_content_int row0field_name"owned"connection1
[21:31:19] [DEBUGCMySQLResult::GetRowDataByName row'0'field"owned"data"0"
[21:31:19] [DEBUGcache_get_field_content row0field_name"village"connection1max_len25
[21:31:19] [WARNINGCMySQLResult::GetRowDataByName field not found ("village")
[
21:31:19] [DEBUGcache_get_field_content_int row0field_name"price"connection1
[21:31:19] [DEBUGCMySQLResult::GetRowDataByName row'0'field"price"data"5000"
[21:31:19] [DEBUGcache_get_field_content_int row0field_name"workers"connection1
[21:31:19] [DEBUGCMySQLResult::GetRowDataByName row'0'field"workers"data"0"
[21:31:19] [DEBUGcache_get_field_content_int row0field_name"ULL"connection1
[21:31:19] [WARNINGCMySQLResult::GetRowDataByName field not found ("ULL")
[
21:31:19] [ERRORcache_get_field_content_int invalid datatype
[21:31:19] [DEBUGcache_get_field_content_int row0field_name"workersAccepting"connection1
[21:31:19] [DEBUGCMySQLConnection::Connect connection was successful
ersAccepting
", data: "0"
[21:31:19] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
[21:31:19] [DEBUG] cache_get_field_content_int - row: 0, field_name: "
profit", connection: 1
[21:31:19] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "
profit", data: "0"
[21:31:19] [DEBUG] cache_get_field_content_int - row: 0, field_name: "
contract", connection: 1
[21:31:19] [DEBUG] CMySQLResult::GetRowDataByName - row: '0', field: "
contract", data: "36000"
[21:31:19] [DEBUG] cache_delete - cache_id: 1, connection: 1
[21:31:19] [DEBUG] CMySQLResult::~CMySQLResult() - deconstructor called
[21:31:19] [DEBUG] CMySQLHandle::DeleteSavedResult - result deleted
[21:31:19] [DEBUG] cache_get_row_count - connection: 1
[21:31:19] [WARNING] cache_get_row_count - no active cache
[21:31:19] [DEBUG] CMySQLConnection::Connect - connection was successful
[21:31:19] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
[21:31:19] [DEBUG] CMySQLConnection::Connect - connection was successful
[21:31:19] [DEBUG] CMySQLConnection::Connect - auto-reconnect has been enabled
[21:31:19] LOADING
[21:31:19] 1
[21:31:19] ing
[21:31:19] Blueberry village  2
[21:31:19] Blueberry village
[21:31:19] e
[21:31:19] 5000 KAINA
[21:31:19] 0 DARBUOTŸw-I
[21:31:19] 0 DARBUOTOˆ
[21:31:19] 0 ISIDARBINIMAS
[21:31:19] 0 PROFIT
[21:31:19] 36000 KONTRAKT
[21:31:19] Blueberry transport shipping Blueberry village uћkrauta
[21:31:19] X : -49.871 Y : -269.363 Z : 6.633 uћkrauta
[21:31:19] 
Reply
#2

Put
pawn Код:
cache_delete(result);
after }, not before it. This happened because you deleted the result right when the reading of the first row finished.

Also, replace
pawn Код:
for(new i; i < cache_get_row_count(); i++){
with
pawn Код:
for(new i, j = cache_get_row_count(); i < j; i++){
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)