[Include] Easy MySQL - Simplifying the usage of MySQL queries!
#41

Quote:
Originally Posted by Private200
Посмотреть сообщение
Even if old, I believe my MySQL include is easier to be understood and used: https://sampforum.blast.hk/showthread.php?tid=609990
Go to ur post this include easier all of them.
Reply
#42

Quote:
Originally Posted by Max_Andolini
Посмотреть сообщение
Go to ur post this include easier all of them.
You still got that toxic attitude after years. I am not advertising nor trying to get people to my include; I had totally forgotten I had released it. Try to appreciate other's work if you want yours to get appreciated.. what a mentality.
Reply
#43

Quote:
Originally Posted by Private200
Посмотреть сообщение
Even if old, I believe my MySQL include is easier to be understood and used: https://sampforum.blast.hk/showthread.php?tid=609990
No offense, but your include is a bit far from being better and easier than that.
Reply
#44

Hey max, rep+ for this i love it but i was wonder if you can go to the other level and make a tutorial about using some of the functions that aren't the basic. The samp community would greatly appreciate.
Reply
#45

Quote:
Originally Posted by Akeem
Посмотреть сообщение
Hey max, rep+ for this i love it but i was wonder if you can go to the other level and make a tutorial about using some of the functions that aren't the basic. The samp community would greatly appreciate.
Thank you. Look here for tutorial. https://github.com/ThreeKingz/easy-m...ster/README.md
Reply
#46

Wow, gonna port my account saving to mysql, +REP for you!
Reply
#47

Update published.

-Added more logtype.
-Small changes.
-Added every query error print.

https://github.com/ThreeKingz/easy-m...easy-mysql.inc
Reply
#48

Quote:
Originally Posted by JR_Junior
Посмотреть сообщение
The following code is not working:
PHP код:
    new string[128], names[24],money;
    new 
handle SQL::OpenEx(SQL::MREAD"Accounts""", -110, -1"Money");
    
SQL::ReadRetrievedRows(handlei)
    {
        
SQL::ReadString(handle"AccountName"names24i);
        
SQL::ReadInt(handle"Money"moneyi);
        
format(stringsizeof(string), "Name %s | Money: %d"names,money);
        
SendClientMessage(playerid, -1string);
    }
    
SQL::Close(handle); 
Accounts in DB: 7

In the Mysql log:
PHP код:
[13:42:36] [DEBUGmysql_query(1"SELECT * FROM `Accounts` WHERE `Money`='' ORDER BY `Money` DESC LIMIT 10 "1)
[
13:42:36] [DEBUGCHandle::Execute(this=0x4f8c170type=3query=0x6705fd0)
[
13:42:36] [DEBUGCConnection::Execute(query=0x6705fd0this=0x674f80connection=0x4fa5968)
[
13:42:36] [DEBUGCQuery::Execute(this=0x6705fd0connection=0x4fa5968)
[
13:42:36] [INFOquery "SELECT * FROM `Accounts` WHERE `Money`='' ORDER BY `Money` DESC LIMIT 10 " successfully executed within 0.616 milliseconds
[13:42:36] [DEBUGCResultSet::Create(connection=0x4fa5968query_str='SELECT * FROM `Accounts` WHERE `Money`='' ORDER BY `Money` DESC LIMIT 10 ')
[
13:42:36] [DEBUGcreated new resultset '0x6710788'
[13:42:36] [DEBUGfetched MySQL result '0x66f8990'
[13:42:36] [DEBUGallocated 0 bytes for PAWN result
[13:42:36] [DEBUGCHandle::Execute - return valuetrue
[13:42:36] [DEBUGmysql_query: return value'1'
[13:42:36] [DEBUGcache_is_valid(1)
[
13:42:36] [DEBUGcache_is_valid: return value'true'
[13:42:36] [DEBUGcache_get_row_count(0x05FFF1E0)
[
13:42:36] [DEBUGcache_get_row_count: return value'1'
[13:42:36] [DEBUGcache_get_row_count(0x05FFF1D8)
[
13:42:36] [DEBUGcache_get_row_count: return value'1'
[13:42:36] [DEBUGcache_is_valid(1)
[
13:42:36] [DEBUGcache_is_valid: return value'true'
[13:42:36] [DEBUGcache_delete(1)
[
13:42:36] [DEBUGcache_delete: return value'1' 
Tried too: new handle = SQL::Open(SQL::MREAD, "Accounts", "Money", -1, "", -1, "", -1, -1, "Money");

But no data in chat!
Update include and try this.

https://github.com/ThreeKingz/easy-m...easy-mysql.inc

PHP код:
    new string[128], names[24],money;
    new 
handle SQL::OpenEx(SQL::MREAD"Accounts""", -110, -1"Money");
    
SQL::ReadRetrievedRows(handlei)
    {
        
SQL::ReadString(handle"AccountName"names24i);
        
SQL::ReadInt(handle"Money"moneyi);
        
format(stringsizeof(string), "Name %s | Money: %d"names,money);
        
SendClientMessage(playerid, -1string);
    }
    
SQL::Close(handle); 
Reply
#49

Quote:
Originally Posted by Max_Andolini
Посмотреть сообщение
Update include and try this.

https://github.com/ThreeKingz/easy-m...easy-mysql.inc

PHP код:
    new string[128], names[24],money;
    new 
handle SQL::OpenEx(SQL::MREAD"Accounts""", -110, -1"Money");
    
SQL::ReadRetrievedRows(handlei)
    {
        
SQL::ReadString(handle"AccountName"names24i);
        
SQL::ReadInt(handle"Money"moneyi);
        
format(stringsizeof(string), "Name %s | Money: %d"names,money);
        
SendClientMessage(playerid, -1string);
    }
    
SQL::Close(handle); 
Thanks for this update!

But I get this error:
PHP код:
...\pawno\include\easy-mysql.inc(191) : warning 213tag mismatch
...\pawno\include\easy-mysql.inc(254) : warning 213tag mismatch
...\pawno\include\easy-mysql.inc(307) : warning 213tag mismatch
...\pawno\include\easy-mysql.inc(370) : warning 213tag mismatch
...\pawno\include\easy-mysql.inc(402) : warning 213tag mismatch
...\pawno\include\easy-mysql.inc(463) : warning 213tag mismatch
...\pawno\include\easy-mysql.inc(516) : warning 213tag mismatch
...\pawno\include\easy-mysql.inc(553) : warning 213tag mismatch
...\pawno\include\easy-mysql.inc(606) : warning 213tag mismatch
...\pawno\include\easy-mysql.inc(638) : warning 213tag mismatch
...\pawno\include\easy-mysql.inc(2097) : warning 213tag mismatch
...\pawno\include\easy-mysql.inc(2393) : warning 213tag mismatch
...\pawno\include\easy-mysql.inc(2407) : warning 213tag mismatch
...\pawno\include\easy-mysql.inc(2462) : warning 213tag mismatch 
PHP код:
if(mysql_errno(SQL::ReadCache[i]) != 0
Reply
#50

Quote:
Originally Posted by JR_Junior
Посмотреть сообщение
Thanks for this update!

But I get this error:
PHP код:
...\pawno\include\easy-mysql.inc(191) : warning 213tag mismatch
...\pawno\include\easy-mysql.inc(254) : warning 213tag mismatch
...\pawno\include\easy-mysql.inc(307) : warning 213tag mismatch
...\pawno\include\easy-mysql.inc(370) : warning 213tag mismatch
...\pawno\include\easy-mysql.inc(402) : warning 213tag mismatch
...\pawno\include\easy-mysql.inc(463) : warning 213tag mismatch
...\pawno\include\easy-mysql.inc(516) : warning 213tag mismatch
...\pawno\include\easy-mysql.inc(553) : warning 213tag mismatch
...\pawno\include\easy-mysql.inc(606) : warning 213tag mismatch
...\pawno\include\easy-mysql.inc(638) : warning 213tag mismatch
...\pawno\include\easy-mysql.inc(2097) : warning 213tag mismatch
...\pawno\include\easy-mysql.inc(2393) : warning 213tag mismatch
...\pawno\include\easy-mysql.inc(2407) : warning 213tag mismatch
...\pawno\include\easy-mysql.inc(2462) : warning 213tag mismatch 
PHP код:
if(mysql_errno(SQL::ReadCache[i]) != 0
Update again.
Reply
#51

Quote:
Originally Posted by Max_Andolini
Посмотреть сообщение
Update again.
Now:
PHP код:
...\gamemodes\GM.pwn(2046) : error 035argument type mismatch (argument 4
PHP код:
new handle SQL::OpenEx(SQL::MREAD"Accounts""", -110, -1"Money"); 
Reply
#52

Thank you very much for this update!
It's working perfectly now.

Keep improving this wonderful include.
Reply
#53

PHP код:
SQL::DeleteRowEx2
SQL
::GetStringEntryEx2
SQL
::t_GetStringEntryEx2
SQL
::GetIntEntryEx2
SQL
::GetFloatEntryEx2
SQL
::SetIntEntryEx2
SQL
::SetStringEntry2
SQL
::SetStringEntryEx2
SQL
::SetFloatEntryEx2
SQL
::RowExistsEx2
SQL
::DeleteRow3 
All these functions use the "%e" specifier using the normal format instead of mysql_format, so they won't work. I noticed this when I tried using RowExistsEx2.
Reply
#54

Quote:
Originally Posted by CantBeJohn
Посмотреть сообщение
PHP код:
SQL::DeleteRowEx2
SQL
::GetStringEntryEx2
SQL
::t_GetStringEntryEx2
SQL
::GetIntEntryEx2
SQL
::GetFloatEntryEx2
SQL
::SetIntEntryEx2
SQL
::SetStringEntry2
SQL
::SetStringEntryEx2
SQL
::SetFloatEntryEx2
SQL
::RowExistsEx2
SQL
::DeleteRow3 
All these functions use the "%e" specifier using the normal format instead of mysql_format, so they won't work. I noticed this when I tried using RowExistsEx2.
Send me your code.
Reply
#55

Quote:
Originally Posted by Max_Andolini
Посмотреть сообщение
Send me your code.
It has nothing to do with my code, I'm simply pointing out that as it is, there's multiple sections throughout the include that uses %e with "format" instead of "mysql_format" for directly escaping strings; but only mysql_format supports %e. Once I edited the include (in my case specifically; RowExistsEx2), my code worked perfectly.
Reply
#56

PHP код:
LoadPlayerBankCards(playerid)
{
    new 
p_name_inside_f[MAX_PLAYER_NAME], Query[164], DBResult:GetPlayerBankCardsDialog_String[226];
    
    
GetPlayerName(playeridp_name_inside_fsizeof(p_name_inside_f));

    
format(Querysizeof(Query), "SELECT * FROM `bank-cards` WHERE `username` = '%s'"DB_Escape(p_name_inside_f));

    
format(Dialog_Stringsizeof(Dialog_String), "\tBaratis Saxeli\tTanxa\n");

    
GetPlayerBankCards db_query(UsersQuery);

    if(
db_num_rows(GetPlayerBankCards))
    {

        for(new 
ii<db_num_rows(GetPlayerBankCards); i++)
        {
            new 
card_name[64], card_cashcard_idcards_info[64];

            
db_get_field_assoc(GetPlayerBankCards"cardname"card_namesizeof(card_name));
            
card_cash db_get_field_assoc_int(GetPlayerBankCards"cash");
            
card_id db_get_field_assoc_int(GetPlayerBankCards"id");

            
p_bank_card[playerid][p_bank_card_loaded[playerid]][cash] = card_cash;
            
p_bank_card[playerid][p_bank_card_loaded[playerid]][b_c_id] = card_id;
            
strcat(p_bank_card[playerid][p_bank_card_loaded[playerid]][name], card_name);
            
p_bank_card_loaded[playerid]++;

            
format(cards_infosizeof(cards_info), "\t%s\t%d\n"card_namecard_cash);
            
strcat(Dialog_Stringcards_info);
            
            
db_next_row(GetPlayerBankCards);
        }
    }
    else
    {
        
SendClientMessage(playerid, -1"Tqven Ar Gaqvt Sabanko Baratebi!");
    }
    
db_free_result(GetPlayerBankCards);

    
ShowPlayerDialog(playerid81DIALOG_STYLE_TABLIST_HEADERS"Sabanko Baratebi"Dialog_String"Sworia""Bugia");

    return 
1;    

How can i make this using Easy MySQL?
Reply
#57

I have to say, it's best you stick to original MySQL. I've tried making a gamemode before with this include and not to be rude, it was pretty shit. I had to rewrite a 7k line code on MySQL then, and I've decided to never use this again.
Reply
#58

Quote:
Originally Posted by Amagida
Посмотреть сообщение
PHP код:
LoadPlayerBankCards(playerid)
{
    new 
p_name_inside_f[MAX_PLAYER_NAME], Query[164], DBResult:GetPlayerBankCardsDialog_String[226];
    
    
GetPlayerName(playeridp_name_inside_fsizeof(p_name_inside_f));
    
format(Querysizeof(Query), "SELECT * FROM `bank-cards` WHERE `username` = '%s'"DB_Escape(p_name_inside_f));
    
format(Dialog_Stringsizeof(Dialog_String), "\tBaratis Saxeli\tTanxa\n");
    
GetPlayerBankCards db_query(UsersQuery);
    if(
db_num_rows(GetPlayerBankCards))
    {
        for(new 
ii<db_num_rows(GetPlayerBankCards); i++)
        {
            new 
card_name[64], card_cashcard_idcards_info[64];
            
db_get_field_assoc(GetPlayerBankCards"cardname"card_namesizeof(card_name));
            
card_cash db_get_field_assoc_int(GetPlayerBankCards"cash");
            
card_id db_get_field_assoc_int(GetPlayerBankCards"id");
            
p_bank_card[playerid][p_bank_card_loaded[playerid]][cash] = card_cash;
            
p_bank_card[playerid][p_bank_card_loaded[playerid]][b_c_id] = card_id;
            
strcat(p_bank_card[playerid][p_bank_card_loaded[playerid]][name], card_name);
            
p_bank_card_loaded[playerid]++;
            
format(cards_infosizeof(cards_info), "\t%s\t%d\n"card_namecard_cash);
            
strcat(Dialog_Stringcards_info);
            
            
db_next_row(GetPlayerBankCards);
        }
    }
    else
    {
        
SendClientMessage(playerid, -1"Tqven Ar Gaqvt Sabanko Baratebi!");
    }
    
db_free_result(GetPlayerBankCards);
    
ShowPlayerDialog(playerid81DIALOG_STYLE_TABLIST_HEADERS"Sabanko Baratebi"Dialog_String"Sworia""Bugia");
    return 
1;    

How can i make this using Easy MySQL?
PHP код:
LoadPlayerBankCards(playerid)
{
    new 
p_name_inside_f[MAX_PLAYER_NAME], Dialog_String[226];
    
GetPlayerName(playeridp_name_inside_fsizeof(p_name_inside_f));
    
format(Dialog_Stringsizeof(Dialog_String), "\tBaratis Saxeli\tTanxa\n");
    if(
SQL::RowExistsEx("bank-cards""username"p_name_inside_f)) 
    {    
        new 
handle SQL::OpenEx(SQL::MREAD"bank-cards""username"p_name_inside_f); 
        
SQL::ReadRetrievedRows(handlei)
        {
            
SQL::ReadString(handle"cardname"p_bank_card[playerid][p_bank_card_loaded[playerid]][name], 64i);
            
SQL::ReadInt(handle"cash"p_bank_card[playerid][p_bank_card_loaded[playerid]][cash], i);
            
SQL::ReadInt(handle"id"p_bank_card[playerid][p_bank_card_loaded[playerid]][b_c_id], i);    
            
format(cards_infosizeof(cards_info), "\t%s\t%d\n"p_bank_card[playerid][p_bank_card_loaded[playerid]][name], p_bank_card[playerid][p_bank_card_loaded[playerid]][cash]);
            
strcat(Dialog_Stringcards_info);            
        }
        
SQL::Close(handle);
    }
    else
    {
        
SendClientMessage(playerid, -1"Tqven Ar Gaqvt Sabanko Baratebi!");
    }
    
ShowPlayerDialog(playerid81DIALOG_STYLE_TABLIST_HEADERS"Sabanko Baratebi"Dialog_String"Sworia""Bugia");
    return 
1;    

Reply
#59

what about easy-sqlite arn't you developing that
Reply
#60

Quote:
Originally Posted by Max_Andolini
View Post
Version 3.7 released.

PHP Code:
Bugs solved.
Added insert options. (EngineCharset etc.)
Added Charset function in SQL::Connect.
Added Null or not null option in AddTableColumn.
SQL::Connect(const host[], const user[], const password[], const database[], const charset[] = "latin5"debugging 0port 3306bool:autoreconnect truepool_size 2);
new 
handle SQL::Open(SQL::CREATE"database""engine default InnoDB", -1"charset default latin5");
SQL::AddTableColumn(handle, const field_name[], SQL::datatypestype SQL_TYPE_INTmaxlength 11bool:null falsebool:auto_increment falsebool:setprimary falsebool:setindex false)
SQL::Close(handle); 
Great. Can we talk about how these still use the "%e" specifier using normal format instead of mysql_format still though?

PHP Code:
SQL::DeleteRowEx2
SQL
::GetStringEntryEx2
SQL
::t_GetStringEntryEx2
SQL
::GetIntEntryEx2
SQL
::GetFloatEntryEx2
SQL
::SetIntEntryEx2
SQL
::SetStringEntry2
SQL
::SetStringEntryEx2
SQL
::SetFloatEntryEx2
SQL
::RowExistsEx2
SQL
::DeleteRow3 
Meanwhile, normal format doesn't support "%e"; as shown here (https://sampwiki.blast.hk/wiki/Format):



The only one it does support is "%q" but that's irrelevant in this case.

Now just look at RowExistsEx2 from the latest version of this library:

PHP Code:
stock SQL::RowExistsEx2(const table[], const column_where[] = "", const row_identifier[], const column_where2[] = "", const row_identifier2[] = ""row_identifier3 = -1MySQL:connectionHandle MYSQL_DEFAULT_HANDLE)
{
    new 
query[SQL_FORM_LENGTH], query2[SQL_FORM_LENGTH], Cache:resultrows;
    
format(querysizeof(query), "SELECT * FROM `%s` WHERE `%s`='%e'"tablecolumn_whererow_identifier); // HERE.
    
if(!isnull(column_where2) && !isnull(row_identifier2) && row_identifier3 == -1)
    {
        
format(query2sizeof(query2), " AND `%s`='%e'"column_where2row_identifier2); // HERE AS WELL.
        
strcat(queryquery2);
    }
    if(!
isnull(column_where2) && row_identifier3 != -&& isnull(row_identifier2))
    {
        
format(query2sizeof(query2), " AND `%s`='%d'"column_where2row_identifier3);
        
strcat(queryquery2);
    }
    
strcat(query" ");
    
result mysql_query(connectionHandlequery);
    if(
mysql_errno() != 0)
    {
        return 
SQL_Warning("Query could not be completed due to error: %s"query);
    }
    
cache_get_row_count(rows);
    
cache_delete(result);
    if(
rows 0)
    {
        return 
rows;
    }
    return 
0;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)