Jump to content

mysql bigint > long long c++


Go to solution Solved by Johnny69,

Recommended Posts

Hello, im writing own offline shops and i have a problem that i cant deal with.

I encountered a problem with getting the total number of yang from the currency safebox. The type of data storage in the column is "bigint", the equivalent to "long long" in c++.
I tried to do it by all means but the number after reading is a minus value. When i set the data type to "int" everything works as it should but this data type is unfortunately too small.

 

Any ideas anyone has?

Edited by Crowlai
Link to comment
Share on other sites

2 hours ago, Johnny69 said:

How do you convert data from MYSQL_ROW to long long in your code ?

 

For example:
 


    char* playerOffYang;
    char* playerOffWon;

    long long playerOfflineYang;
    long long playerOfflineWon;

    SQLMsg * pkMsg(DBManager::instance().DirectQuery("SELECT collected_yang, collected_won .............."));
    SQLResult * pRes = pkMsg->Get();

    if (pRes->uiNumRows > 0){
        MYSQL_ROW row;
        while ((row = mysql_fetch_row(pRes->pSQLResult)) != NULL){
            playerOfflineYang = row[0];
            playerOfflineWon = row[1];
        }
    }
    
    str_to_number(playerOfflineYang, playerOffYang);
    str_to_number(playerOfflineWon, playerOffWon);

Edited by Crowlai
Link to comment
Share on other sites

  • Solution

Try it like this:

    long long playerOfflineYang = 0;
    long long playerOfflineWon = 0;

	// Add LIMIT 1
    SQLMsg * pkMsg(DBManager::instance().DirectQuery("SELECT collected_yang, collected_won"));
    SQLResult * pRes = pkMsg->Get();

    if (pRes->uiNumRows > 0){
        MYSQL_ROW row = mysql_fetch_row(pRes->pSQLResult);
        if(row)
		{
			str_to_number(playerOfflineYang, row[0]);
			str_to_number(playerOfflineWon, row[1]);
        }
    }

 

Link to comment
Share on other sites

1 hour ago, Johnny69 said:

Well, maybe the value is ok but you print it with the wrong format (%d maybe).

Long long variables need to printed with %lld format.

 

 

Good observation, check how i will have some time.

 

1 hour ago, Moț said:

https://metin2.download/picture/XtHh63bkn57vats5gHV8j0f1dL5095Ap/.png BIGINT, maybe there in your code is mistakes

 

 

I did not think about it, i will also check how i will have some time.

 

I'll let you know what and how probably in the evening;)

 

Edited by Metin2 Dev
Core X - External 2 Internal
Link to comment
Share on other sites

2 hours ago, Johnny69 said:

Well, maybe the value is ok but you print it with the wrong format (%d maybe).

Long long variables need to printed with %lld format.

 

 


Apr 07 19:42:09 :: [LOG] Request received to send data info 100000000000 yang, 1 won to client.
Apr 07 19:42:09 :: [LOG] 1000000000 yang, 0 won paid out successfully

 

I cant believe i spent so much time trying to do something that worked well only the problem was displaying in sys_log.. I feel stupid.

  • Love 1
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.