1. Hey! Guest! The 35th GMC Jam will take place between November 28th, 12:00 UTC - December 2nd, 12:00 UTC. Why not join in! Click here to find out more!
    Dismiss Notice

Mysql consult limit

Discussion in 'Programming' started by Blade, Nov 9, 2019.

Tags:
  1. Blade

    Blade Member

    Joined:
    Nov 9, 2019
    Posts:
    3
    Hi everyone, i'm new at GameMaker and i'm having some problem whit mysql consult, hope someone can give me some light...

    There is what i'm trying to do:

    I need get some informations from my local database to do an load system, researching and studing a few i found some way using the function "http_get()". The problem is, i can't consult more than 14 times simultaneously, the 15 consult will be "null" and block any new consult for few seconds. I don't know if this way is the best to do that, i already try updated mysql, change max limit on my.config and nothing changes.

    I'm using something like that:

    ngplayerid = http_get("localh/db/gmdb.php?...
    ngplayeracc = http_get(localh/db/gmdb.php?...
    ngplayername = http_get("localh/db/gmdb.php?...
    ngplayerlvl = http_get("localh/db/gmdb.php?...
    ngplayerexp = http_get("localh/db/gmdb.php?...
    for all table etc...

    and:

    if ds_map_find_value(async_load, "id") == ngplayerid{ // player id
    if ds_map_find_value(async_load, "status") == 0{
    ngetplayerid = ds_map_find_value(async_load, "result");
    }else{
    ngetplayerid = 'nulo';
    }
    }
    for all table etc...

    Whit this system i can load only a few consults simultaneously and after 14 consults the result always will be "null". Someone know what i'm doing wrong? Or some new way to do that...

    Thank you in advanced!
     
  2. Nocturne

    Nocturne Friendly Tyrant Forum Staff Admin

    Joined:
    Apr 13, 2016
    Posts:
    6,977
    I suspect you may simply have reached a limit in the amount of requests that can be processed by GMS at a time. It might be worthwhile making a bug report and including a link to a test project and getting YYG to confirm this is the case (in which case you should also request that it be documented) or not (in which case it's a bug and should be fixed). Once you've done that, and knowing there is a limit on these things at the moment, you can then modify your code so that it fires off, say, 10 requests at a time... so initialise the first ten then in the async event do the next, etc... until you have all the data then continue the game.
     
  3. Catan

    Catan Member

    Joined:
    Jun 20, 2016
    Posts:
    751
    Assuming the problem is related to what Nocturne mentioned, isn’t it possible for you to return all the data in a single http query? Looks like you are trying yo get a single piece of data with every request, but even if it worked, this is incredibly inefficient.
     
    Last edited: Nov 10, 2019 at 8:49 AM
    Binsk and Nocturne like this.
  4. Blade

    Blade Member

    Joined:
    Nov 9, 2019
    Posts:
    3
    Thank you to aswner... I just can think on some GMS limit of requests too, i will try make an bug report.

    Since is that the problem, i just request few at a time... But the future will be the problem, alot more data to save will take alot more time to save. I don't know what is the right way to do this work.
     
  5. Blade

    Blade Member

    Joined:
    Nov 9, 2019
    Posts:
    3
    Thank you to aswner... How can i return all data in a single query? Can you give me some example... All examples i found is similar like that.

    I need return right number to my actions, like that:

    obj_control.lvl=real(obj_getDB.ngetplayerlvl);
    obj_control.xp=real(obj_getDB.ngetplayerexp);
    obj_control.hp=real(obj_getDB.ngetplayerhealth);

    How can i update this data returning all data in a single http query for that?
     
  6. Catan

    Catan Member

    Joined:
    Jun 20, 2016
    Posts:
    751
    First you’ll need to edit your php file, fetching all the data you require from the database and returning it in a format you can read in GM, like JSON, CSV, or simply one value on every line.

    In GM then you only need a one http request, but since you get all the data back in a single string, you'll have to parse (split) it into the different values, hence the need for a data format that can easily be processed by you.

    It all depends on what you return from the php though, can’t really give you an example of the GML part unless this is defined first.
     
    Last edited: Nov 14, 2019 at 9:05 AM
    Nocturne likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice