1 registered members (AndrewAMD),
1,643
guests, and 2
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
SQL queries
#213514
06/28/08 13:57
06/28/08 13:57
|
Joined: Oct 2004
Posts: 290 Latvia
Leonardo
OP
Member
|
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: fastlane69]
#213553
06/28/08 22:10
06/28/08 22:10
|
Joined: Oct 2004
Posts: 290 Latvia
Leonardo
OP
Member
|
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
Senior Expert
|
Senior Expert
Joined: Mar 2003
Posts: 5,377
USofA
|
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
OP
Member
|
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 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]
#213579
06/29/08 08:06
06/29/08 08:06
|
Joined: Mar 2003
Posts: 5,377 USofA
fastlane69
Senior Expert
|
Senior Expert
Joined: Mar 2003
Posts: 5,377
USofA
|
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 -- 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: --
//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:
"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
Senior Expert
|
Senior Expert
Joined: Mar 2003
Posts: 5,377
USofA
|
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.
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
OP
Member
|
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! 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
"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
Senior Expert
|
Senior Expert
Joined: Mar 2003
Posts: 5,377
USofA
|
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.
|
|
|
|