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

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.
Reply

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".
Reply

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

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.
Reply

you using the correct library ?
Reply

Yet another good release by you Good job
Reply

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.
Reply

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!
Reply

That's what I've got.
Reply

Please upload link !
Reply

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

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

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

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).
Reply

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

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.
Reply

for sure this is the best plugin that is released
Reply

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
Reply

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);
}
Reply

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


Forum Jump:


Users browsing this thread: 4 Guest(s)