SA-MP Forums Archive
[Plugin] [REL] MySQL Plugin (Now on github!) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Plugin Development (https://sampforum.blast.hk/forumdisplay.php?fid=18)
+--- Thread: [Plugin] [REL] MySQL Plugin (Now on github!) (/showthread.php?tid=56564)



Re: Re : [REL] MySQL Plugin (****** Project) - ReneG - 09.03.2013

Quote:
Originally Posted by Morozzzko
Посмотреть сообщение
Seems like you did not quite understand me. I said RETURN last insert id. Not just use it. I am not completely stupid.
Let me give you an example of what I need.
Код:
stock foo() {
    mysql_query(...);
    ...
    return mysql_insert_id();
}

main() {
     printf("Last insert ID: %d", foo());
}
I can not do that anymore, can I? The stuff is threaded and I need the result right now. And when I say right now I mean it.
---
Yeah I know the code makes no sense. But that is just an example. I use returns in more complex scripts. I want everything organized and good. This threaded-only stuff just makes me write bad, disorganized code.
Then use the old plugin, and quit complaining! You've already answered yourself. You can't return a value from a threaded query, that's just pure logic! Just code whatever you're doing with the insert id into the according callback.


Re: [REL] MySQL Plugin (****** Project) - IstuntmanI - 13.03.2013

Quote:
Originally Posted by Edvin
Посмотреть сообщение
How to use mysql_insert_it( ); on R7 or above ?

I have this code:
Код:
format( gsQuery, 512, "INSERT INTO `Clans` VALUES(0,'%s','%s','1','%.3f','%.3f','%.3f','%.3f','0','0','0','0','0','0','0','0','0','0')", clanname, PlayerName( playerid ), c_Pos[ 0 ], c_Pos[ 1 ], c_Pos[ 2 ], c_Pos[ 3 ] );
		mysql_function_query( g_Handle, gsQuery, false, "", "" );

		PlayerInfo[ playerid ][ ID ] 	= mysql_insert_id( g_Handle );
printf( "ClanID: %d", PlayerInfo[ playerid ][ ID ] );
It returns me "ClanID: 0".
mysql_insert_id have to be used in the thread. Make a thread for "INSERT".


Re: [REL] MySQL Plugin (****** Project) - FHMCLAN - 15.03.2013

Can you upload the MySQL Plugin on your ****** Site?


AW: [REL] MySQL Plugin (****** Project) - surrender - 15.03.2013

Hey guys,
after updating my mysql.dll, a_mysql.inc and my script to R15 from R6-2 I got these errors on my server startup:

Код:
[00:48:33]    Error: Function not registered: 'mysql_debug'
[00:48:33]    Error: Function not registered: 'mysql_connect'
[00:48:33]    Error: Function not registered: 'mysql_set_charset'
[00:48:33]    Error: Function not registered: 'mysql_function_query'
[00:48:33]    Error: Function not registered: 'mysql_close'
[00:48:33]    Error: Function not registered: 'mysql_num_rows'
[00:48:33]    Error: Function not registered: 'mysql_free_result'
[00:48:33]    Error: Function not registered: 'mysql_real_escape_string'
[00:48:33]    Error: Function not registered: 'mysql_num_fields'
[00:48:33]    Error: Function not registered: 'cache_get_data'
[00:48:33]    Error: Function not registered: 'cache_get_row'
[00:48:33] Script[gamemodes/samp2k13.amx]: Run time error 19: "File or function is not found"
"#include <a_mysql>" and "plugins mysql [...]" not missing.


Re: [REL] MySQL Plugin (****** Project) - Black Wolf - 16.03.2013

you using the correct library ?


Re: [REL] MySQL Plugin (****** Project) - KyleSta123 - 16.03.2013

Yet another good release by you Good job


AW: Re: [REL] MySQL Plugin (****** Project) - surrender - 16.03.2013

Quote:
Originally Posted by Black Wolf
Посмотреть сообщение
you using the correct library ?
You mean the libmysql.dll ? Should be.. The mysql.dll and a_mysql.inc also are the correct ones.


Re: [REL] MySQL Plugin (****** Project) - Black Wolf - 16.03.2013

inc file doesnt matter's that is just needed for compiling.You should have mysql.dll in your plugins folder and libmysql.dll with the main folder!


AW: [REL] MySQL Plugin (****** Project) - surrender - 16.03.2013

That's what I've got.


Re: [REL] MySQL Plugin (****** Project) - -CyRAX - 17.03.2013

Please upload link !


Re: [REL] MySQL Plugin (****** Project) - Shadow_ - 17.03.2013

Goto the ****** page for a download link.


Re: [REL] MySQL Plugin (****** Project) - newbienoob - 18.03.2013

I got this error
"Could not locate the procedure entry point __ crtCreateSymbolicLinkW in dynamic link library MSVCR110.dll"


Re: [REL] MySQL Plugin (****** Project) - Vince - 18.03.2013

So, tell me where you got that DLL. Install is properly: http://www.microsoft.com/en-us/downl....aspx?id=30679


Re: [REL] MySQL Plugin (****** Project) - newbienoob - 18.03.2013

I've fixed the problem just now The problem is I downloaded a wrong libmysql.dll(link in the main post is down, so I ******d).


Re: [REL] MySQL Plugin (****** Project) - niklasbollmer - 18.03.2013

Reupload: http://dl-it.tk/ul-8b5k


Re: [REL] MySQL Plugin (****** Project) - Jeroen52 - 18.03.2013

Quote:
Originally Posted by niklasbollmer
View Post
The re-upload was not needed, the download only moved and the old urls are not removed in the first post.
Just search for PROJECT HOME in the first post, it is really big.


Re: [REL] MySQL Plugin (****** Project) - Stream - 20.03.2013

for sure this is the best plugin that is released


Re: [REL] MySQL Plugin (****** Project) - FHMCLAN - 24.03.2013

Hey,

Which Command can I use for Get float in R7?
Code:
stock Float:mysql_GetFloat(Table[], Field[], Where[], Is[])
{
	new Query[128], Float:sqlfloat;
	mysql_real_escape_string(Table, Table);
	mysql_real_escape_string(Field, Field);
	mysql_real_escape_string(Where, Where);
	mysql_real_escape_string(Is, Is);
	format(Query, sizeof(Query), "SELECT `%s` FROM `%s` WHERE `%s` = '%s'", Field, Table, Where, Is);
	mysql_function_query(MYSQLConnection,Query,true,"QueryFinished","");
	mysql_store_result();
	mysql_fetch_float(sqlfloat);
	mysql_free_result();
	return sqlfloat;
}
mysql_fetch_float(sqlfloat); // It dosn't works in R7!

Any ideas


Re: [REL] MySQL Plugin (****** Project) - Dan.. - 24.03.2013

Quote:
Originally Posted by FHMCLAN
View Post
Hey,

Which Command can I use for Get float in R7?
Code:
stock Float:mysql_GetFloat(Table[], Field[], Where[], Is[])
{
	new Query[128], Float:sqlfloat;
	mysql_real_escape_string(Table, Table);
	mysql_real_escape_string(Field, Field);
	mysql_real_escape_string(Where, Where);
	mysql_real_escape_string(Is, Is);
	format(Query, sizeof(Query), "SELECT `%s` FROM `%s` WHERE `%s` = '%s'", Field, Table, Where, Is);
	mysql_function_query(MYSQLConnection,Query,true,"QueryFinished","");
	mysql_store_result();
	mysql_fetch_float(sqlfloat);
	mysql_free_result();
	return sqlfloat;
}
mysql_fetch_float(sqlfloat); // It dosn't works in R7!

Any ideas
Update your plugin or use this code:
Code:
/**
 * Copyright © 2013 - Dan
 * All rights reserved.
 */

// Gets an int from the MySQL result using a field name.
stock mysql_fetch_field_row_int(fieldname[], connectionHandle) {
	new ret[64];
	mysql_fetch_field_row(ret, fieldname, connectionHandle);
	return strval(ret);
}

// Gets a float from the MySQL result using a field name.
forward Float:mysql_fetch_field_row_float(fieldname[], connectionHandle);
stock Float:mysql_fetch_field_row_float(fieldname[], connectionHandle) {
	new ret[64];
	mysql_fetch_field_row(ret, fieldname, connectionHandle);
	return floatstr(ret);
}

// Gets an int from the cache using a field ID.
stock cache_get_row_int(row, idx, connectionHandle) {
	new ret[64];
	cache_get_row(row, idx, ret, connectionHandle, sizeof(ret));
	return strval(ret);
}

// Gets a float from the cache using a field ID.
forward Float:cache_get_row_float(row, idx, connectionHandle);
stock Float:cache_get_row_float(row, idx, connectionHandle) {
	new ret[64];
	cache_get_row(row, idx, ret, connectionHandle, sizeof(ret));
	return floatstr(ret);
}

// Gets an int from the cache using a field name.
stock cache_get_field_content_int(row, const fieldname[], connectionHandle) {
	new ret[64];
	cache_get_field_content(row, fieldname, ret, connectionHandle, sizeof(ret));
	return strval(ret);
}

// Gets a float from the cache using a field name.
forward Float:cache_get_field_content_float(row, const fieldname[], connectionHandle);
stock Float:cache_get_field_content_float(row, const fieldname[], connectionHandle) {
	new ret[64];
	cache_get_field_content(row, fieldname, ret, connectionHandle, sizeof(ret));
	return floatstr(ret);
}



AW: [REL] MySQL Plugin (****** Project) - Campbell- - 27.04.2013

Thank you, works perfectly fine. I guess it should be covered in the manual, shouldn't it?