Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
MySql modul
#1
Hi.
How to get the data from the second or third row?

local query = mysql_query(handler, "select * from...");
local rowCount = mysql_num_row(query) // rowCount = 4

//Further

local data = mysql_fetch_row(query);

or

local data = mysql_fetch_assoc(query);



I have access to the data of the first row.
Reply
#2
Code:
function queryGetAll(query)
{
    local result = [];
    local mysql_result = mysql_query(database, query);
        
    local count = mysql_num_rows(mysql_result);
    for(local i=0; i<count; i++)
    {
        result.push(mysql_fetch_assoc(mysql_result));
    }
        
    mysql_free_result(mysql_result);
        
    return result;
}
Reply
#3
Squirrel Script
  1. local result = mysql_query(mysqlHandler, "SELECT * FROM `player_items` WHERE `player_id` = " + getGUIDbyLogin(getPlayerName(pid)) + ";");
  2. if(result)
  3. {
  4. local row;
  5. while ((row = mysql_fetch_assoc(result)))
  6. {
  7. callClientFunc(pid, "giveItem", row["instance"], row["amount"]);
  8. }
  9.  
  10. mysql_free_result(result);
  11. }


Reply
#4
Thank you, guys.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  mysql module new problem in 0.1.0 Baster 2 3,631 12.07.2017, 10:58
Last Post: Baster

Forum Jump:


Users browsing this thread: 1 Guest(s)