Posts: 845
	Threads: 3
	Joined: Jun 2010
	
	
 
	
	
		
Quote:
| 
					Originally Posted by Vince  How would I go about handling transactions? I have one instance where I need, or rather want to perform inserts in a loop. Do I simply execute Start->queries->Commit? | 
 Yes, that's pretty much it.
Код:
mysql_tquery(SQL, "START TRANSACTION");
for(new i=0; i < 100; ++i)
    mysql_tquery(SQL, "INSERT INTO foobar (foo) VALUES ('bar')");
mysql_tquery(SQL, "COMMIT");
 
Quote:
| 
					Originally Posted by Mellnik  I think you can only do this with unthreaded queries because otherwise you can't make sure in which order the queries get executed.[...]
 But unless you don't need a feature like ROLLBACK or something you should stay with common threaded queries.
 | 
 You can use transactions with 'mysql_query' and 'mysql_tquery', but not with 'mysql_pquery'. Only 'mysql_pquery' can execute queries in a different order.
Transactions are also good for speed optimizations, because they skip some internal query operations within the MySQL server (table locking and re-indexing I think).
	
 
	
	
	
		
	
 
 
	
	
	
		
	Posts: 845
	Threads: 3
	Joined: Jun 2010
	
	
 
	
	
		
Quote:
| 
					Originally Posted by fordawinzz  Should I declare the threaded function if I don't use it at all? For instance, I want to update a table and I use this query:  
pawn Код: format(E_STRING[szVehicleUpdateString], sizeof E_STRING[szVehicleUpdateString], "UPDATE vehicles SET pos_x=%f, pos_y=%f, pos_z=%f, pos_a=%f, color1=%d, color2=%d, owner='%s', mileage=%f, gas=%d, locked=%d, vworld=%d, interior=%d WHERE plate='%s'", E_VEHICLE[data_saveid][vPosition][0], E_VEHICLE[data_saveid][vPosition][1], E_VEHICLE[data_saveid][vPosition][2], E_VEHICLE[data_saveid][vPosition][3], E_VEHICLE[data_saveid][vColors][0], E_VEHICLE[data_saveid][vColors][1], E_VEHICLE[data_saveid][vOwner], E_VEHICLE[data_saveid][vMileage],
 E_VEHICLE[data_saveid][vGas], E_VEHICLE[data_saveid][vLocked], E_VEHICLE[data_saveid][vVirtualWorld], E_VEHICLE[data_saveid][vInterior], E_VEHICLE[data_saveid][vPlate]);
 mysql_tquery(dbHandle, E_STRING[szVehicleUpdateString], "OnVehicleDataSave", "");
 | 
 You can just use
Код:
mysql_tquery(dbHandle, E_STRING[szVehicleUpdateString]);
 This will only send the UPDATE query and don't call any public function (since you don't specified one).
	
 
	
	
	
		
	
 
 
	
	
	
		
	Posts: 6,129
	Threads: 36
	Joined: Jan 2009
	
	
 
	
	
		Thanks for your work on this plugin maddinat0r, I understand it much more clearly now and fully appreciate the hard work you've put in since you started to work on it. BlueG of course too.
	
	
	
	
		
	
 
 
	
	
	
		
	Posts: 28
	Threads: 7
	Joined: Mar 2011
	
Reputation: 
0
	 
	
	
		Hi, can I use mysql_query and mysql_function_query at one script? I have some code what need to be done with mysql_query to dont mess, but 95% of gamemode I converted to threaded mysql_function_query. Is it gonna work? I remember when I use on R6 threaded+non-threaded in script on one time it crashed gamemode, is it fixed?
	
	
	
	
		
	
 
 
	
	
	
		
	Posts: 845
	Threads: 3
	Joined: Jun 2010
	
	
 
	
		
		
		
		03.04.2014, 10:18 
(
 Последний раз редактировалось maddinat0r; 03.04.2014 в 20:54.
					
					
						Причина: informations -> information, thank you Mellnik :P
)
	
	 
	
		
Quote:
| 
					Originally Posted by ToFFiK  Hi, can I use mysql_query and mysql_function_query at one script? I have some code what need to be done with mysql_query to dont mess, but 95% of gamemode I converted to threaded mysql_function_query. Is it gonna work? I remember when I use on R6 threaded+non-threaded in script on one time it crashed gamemode, is it fixed? | 
 Well, there is a difference between R6 and R38. Like, 2.5 years and 23 other versions (revisions). So it's very likely that it works fine now.
There is (technically) no mysql_function_query anymore, the equivalent is "mysql_tquery". You can also use unthreaded queries with "mysql_query". Take a look at the wiki for more information.
	
 
	
	
	
		
	
 
 
	
	
	
		
	Posts: 43
	Threads: 3
	Joined: Nov 2011
	
Reputation: 
0
	 
	
	
		Hello, 
I have a big problem. My Mysql plugin is no load now. 
I have BlueG R38 mysql plugin(this no load), crashdetect 4.13.1, streamer 2.7.1, Whirlpool and sscanf 2.8.1, and console say: "mysql plugin load filed' 
What's problem? 
Sorry for my bad english, I don't use translators. 
	
	
	
	
		
	
 
 
	
	
	
		
	Posts: 162
	Threads: 5
	Joined: Oct 2012
	
Reputation: 
0
	 
	
	
		Which operating system you use for your server?
Give us that message from the console.
	
	
	
	
		
	
 
 
	
	
	
		
	Posts: 43
	Threads: 3
	Joined: Nov 2011
	
Reputation: 
0
	 
	
	
		Server is in my localhost, win7 64bit. and this is message:
"mysql plugin load:
failed"
	
	
	
	
		
	
 
 
	
	
	
		
	Posts: 161
	Threads: 14
	Joined: Jun 2010
	
Reputation: 
0
	 
	
	
		Do you have "libmysql.dll" in your server folder?
	
	
	
	
		
	
 
 
	
	
	
		
	Posts: 13
	Threads: 1
	Joined: Mar 2011
	
Reputation: 
0
	 
	
	
		Hey,
iґve got a problem with the plugin. Since yesterday, after i changed the root-server time and did some updating. 
The static version got the error: Can't connect to local MySQL server through socket '/tmp/mysql.sock'
After i created a symbolic link via: ln -s /var/run/mysqld/mysqld.sock /tmp/mysql.sock'
Mysql is working, but the gamemode changed to "unknown". Does anybody got a solution for this problem?
Greetings
Blue
	
	
	
	
		
	
 
 
	
	
	
		
	Posts: 11,827
	Threads: 33
	Joined: Dec 2011
	
Reputation: 
0
	 
	
	
		I think it's because you have as host (in mysql_connect) "localhost". Change to "127.0.0.1".
	
	
	
	
		
	
 
 
	
	
	
		
	Posts: 161
	Threads: 14
	Joined: Jun 2010
	
Reputation: 
0
	 
	
	
		Well, I don't know why, but I got a really huge cpu usage of 45% with samp03svr & mysqld. Anyone with the same problems?