BlueG's MySQL - Nested select statements causes crash -
denNorske - 07.01.2017
Hello there
I noticed something weird using MySQL, and I can assume this has something to do with the cache handling?
Here is a short example code of what im doing:
PHP код:
function DoThisFirst()
{
//code
//Parse info i need to call the "DoThisSecond"
mysql_format(connectionHandle, string, sizeof(string), "");
mysql_tquery(connectionHandle, string, "DoThisSecond", "i", parameter);
return 1;
}
function DoThisSecond(parameter)
{
if(cache_get_row_count())
{
//parse info i need for next one (third)
//...
mysql_format(connectionHandle, string, sizeof(string), "");
mysql_tquery(connectionHandle, string, "DoThisThird", "i", parameter); //this crashes the server.
}
else
//return an error
}
function DoThisThird(parameter)
{
if(cache_get_row_count())
{
//and so on
}
else
//return an error
}
If you look at the code, i am trying to do a select statement inside a call for the first select statement, which makes me believe the cache is still active when a new one is called. Shouldn't the plugin be able to differ between those two?
Why does this happen, is it why I think it is?
And how could i get around this issue?
Thanks for explanations
Re: BlueG's MySQL - Nested select statements causes crash -
Vince - 07.01.2017
It might help if you explain what you're trying to achieve. There may be better ways to do it.
Re: BlueG's MySQL - Nested select statements causes crash -
Lordzy - 07.01.2017
You can either use parallel queries or pass the data through mysql_tquery. I'm also suggesting you to read about sub queries.
Re: BlueG's MySQL - Nested select statements causes crash -
denNorske - 07.01.2017
There is a much better way of doing it in my case, and I will do it in a moment.
But currently my situation is related to a race system I have made. The server starts a race, and my database contains a table each for the race information and the checkpoints for the race, based off race ID's.
I was trying to stop the race from launching if the race information for the given ID wasn't found (index 0 - Max_races), or further down the road it would halt if the checkpoints wasn't found.
So that was why i did the nested statements, although i can make separate functions to retrieve the information instead of doing this. My curiosity was more aimed at the way the plugin handled the calls inside eachother, and why it eventually led to a crash.
Quote:
Originally Posted by Lordzy
You can either use parallel queries or pass the data through mysql_tquery. I'm also suggesting you to read about sub queries.
|
I assume you talk about the PQuery? And I will go through the wiki, I bet he has the source published as well.