Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (AndrewAMD, Nymphodora), 1,592 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
SQL queries #213514
06/28/08 13:57
06/28/08 13:57
Joined: Oct 2004
Posts: 290
Latvia
Leonardo Offline OP
Member
Leonardo  Offline OP
Member

Joined: Oct 2004
Posts: 290
Latvia
Hi, I have a small question about the A6MySQL.dll
Right now, I have many instances of one function running at the same time. What would happen if these functions ran separate SQL queries at the same time? Would there be only one (last) resultset, or would there be different resultsets for each function?

Thank you,
Leonardo


"Things of the mind left untested by the senses are useless."
Re: SQL queries [Re: Leonardo] #213548
06/28/08 21:43
06/28/08 21:43
Joined: Mar 2003
Posts: 5,377
USofA
fastlane69 Offline
Senior Expert
fastlane69  Offline
Senior Expert

Joined: Mar 2003
Posts: 5,377
USofA
What is this "one function" you mention?
What does it do?
Code?

In principle, if you send the same query down to the mysql engine 100 times, you should get the same 100 results back every time (unless the entry was updated at that time). Not sure that's what you are asking though.

Re: SQL queries [Re: fastlane69] #213553
06/28/08 22:10
06/28/08 22:10
Joined: Oct 2004
Posts: 290
Latvia
Leonardo Offline OP
Member
Leonardo  Offline OP
Member

Joined: Oct 2004
Posts: 290
Latvia
I have an online poker game, where this one function represents a whole poker table. And there are many instances of this function running at the same time, right now there are about 24 tables (24 functions). The problems is, that the queries are different for each function, depending on the poker table's ID.
I have a table in MySQL, in which each row holds information about one poker table. The queries these functions execute retrieve information from these rows.
My thoughts are that there will be only one result set (the last one)... If I'm right, then what can I do, to work around this problem? Of course I can do a loop that checks if a query is being executed and when it is not, then continue with the function, but that seems like a bit too complicated.


"Things of the mind left untested by the senses are useless."
Re: SQL queries [Re: Leonardo] #213554
06/28/08 22:13
06/28/08 22:13
Joined: Mar 2003
Posts: 5,377
USofA
fastlane69 Offline
Senior Expert
fastlane69  Offline
Senior Expert

Joined: Mar 2003
Posts: 5,377
USofA
Quote:
The problems is, that the queries are different for each function, depending on the poker table's ID.


How so?

Re: SQL queries [Re: fastlane69] #213555
06/28/08 22:24
06/28/08 22:24
Joined: Oct 2004
Posts: 290
Latvia
Leonardo Offline OP
Member
Leonardo  Offline OP
Member

Joined: Oct 2004
Posts: 290
Latvia
SELECT * FROM active_poker_tables WHERE table_id = 'Function ID'

The 'Function ID' is different for each function, depending on what poker table the function represents smile Each function fetches only one row from the database table called "active_poker_tables"


"Things of the mind left untested by the senses are useless."
Re: SQL queries [Re: Leonardo] #213557
06/28/08 23:46
06/28/08 23:46
Joined: Oct 2004
Posts: 290
Latvia
Leonardo Offline OP
Member
Leonardo  Offline OP
Member

Joined: Oct 2004
Posts: 290
Latvia
Seeing as I don' t want to make another post about MySQL, I'm going to ask another question right here. smile
Can a field in the database hold a function, like in Excel? For example, if I have 5 columns that hold different numbers (all above 0 or 0) and I need a column that automatically sums up these values? In excel I could use Field A = SUM of Field B, Field C, Field D, etc. Can this be achieved in MySQL? smile


"Things of the mind left untested by the senses are useless."
Re: SQL queries [Re: Leonardo] #213579
06/29/08 08:06
06/29/08 08:06
Joined: Mar 2003
Posts: 5,377
USofA
fastlane69 Offline
Senior Expert
fastlane69  Offline
Senior Expert

Joined: Mar 2003
Posts: 5,377
USofA
Quote:
Can a field in the database hold a function,


Not quite "hold" a function but yes, the MySQL engine can perform rudimentary (and not so rudimentary) calculations. In our game, what we would normally make an inline function
--
Code:
inline distance(x,y,z){ return)sqrt(x^2+y^2+z^2););} 

--
we calculate by making a call to the MySQL engine via the A6/7 plugin. An example from our code:
--

Code:
 
//Set the distance of SOI People
i = 0;
while (i < num_rows)
{
str_cpy(sql_cmd, "update soi set distance = ");
	str_cat(sql_cmd, "sqrt(pow((select pos_x from position where handle = '");
	str_cat(sql_cmd, send_handles.string[i]);
	str_cat_num(sql_cmd, "') - %f, 2)) + ", cur_pos[0]); 
						
	str_cat(sql_cmd, "sqrt(pow((select pos_y from position where handle = '");
	str_cat(sql_cmd, send_handles.string[i]);
	str_cat_num(sql_cmd, "') - %f, 2)) + ", cur_pos[1]); 
						
	str_cat(sql_cmd, "sqrt(pow((select pos_z from position where handle = '");
	str_cat(sql_cmd, send_handles.string[i]);
	str_cat_num(sql_cmd, "') - %f, 2)) ", cur_pos[2]); 
						
	[...]



For you, something like this might be useful or at least set you in the right direction:

Code:
"SELECT type, SUM(price) FROM products GROUP BY type"; 


MySQL Gurus needed!!!! [Re: Leonardo] #213582
06/29/08 08:19
06/29/08 08:19
Joined: Mar 2003
Posts: 5,377
USofA
fastlane69 Offline
Senior Expert
fastlane69  Offline
Senior Expert

Joined: Mar 2003
Posts: 5,377
USofA
Quote:
The 'Function ID' is different for each function, depending on what poker table the function represents


I am by NO means a DB expert (or even novice), but it seems to me that it would be best for the unique "function ID" to be a unique "table ID" foreign key. And thus you can always uniquely reference each table not by which function run it, but by which "virtual" table(s) represents it.

Code:
SELECT * FROM active_poker_tables WHERE table_id = 'Unique Table ID'


Any MySQL'ers care to chime in and correct, augment, or fling my ignorant BS around, please?

Re: MySQL Gurus needed!!!! [Re: fastlane69] #213585
06/29/08 08:36
06/29/08 08:36
Joined: Oct 2004
Posts: 290
Latvia
Leonardo Offline OP
Member
Leonardo  Offline OP
Member

Joined: Oct 2004
Posts: 290
Latvia
Well, I already have the function I need, now I'm just going to test if it works. But that just adds one more query to the whole query list my function has to execute! frown
And speaking about the functions and poker tables, the 'Function ID' is the same as Unique Table ID. See, when a row is added in active_poker_tables, the server automatically reads this and runs a new poker table function with the information retrieved from this row. And part of the information is the Primary Key, in my table, it is called ID. This ID, is then used by the function - it is written into a variable. By doing this, at least I know that the function ID is always unique and all of the poker tables have a function.
BUT.... this still doesn't solve my problem of many functions performing different queries at the same time and getting noone-knows-what results wink


"Things of the mind left untested by the senses are useless."
Re: MySQL Gurus needed!!!! [Re: Leonardo] #213587
06/29/08 08:50
06/29/08 08:50
Joined: Mar 2003
Posts: 5,377
USofA
fastlane69 Offline
Senior Expert
fastlane69  Offline
Senior Expert

Joined: Mar 2003
Posts: 5,377
USofA
Quote:
this still doesn't solve my problem of many functions performing different queries at the same time and getting noone-knows-what results


For a system (MySQL) that can handle changes on the order of milliseconds, I'm not quite sure that you can send queries down fast enough to get any synchronization issues.

Page 1 of 2 1 2

Moderated by  HeelX, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1