Announcement

Collapse
No announcement yet.

Problem with MariaDB

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Problem with MariaDB

    Hi there !

    First post here, i tried figurint it out myself but i can't find the solution so i'm requesting your help ..

    here's part of my script

    Code:
    local query = "SELECT * FROM vehicles ORDER BY 'ID' ASC;"
        local result = mysql.query(query)
        print(result)
        if(result) then
            local nbrRows = mysql.num_rows()
            if(nbrRows > 0) then
                while true do
                    local row = mysql.get_assoc(result)
    The query is sent and done well, but the plugin dosen't count the rows number

    here is my exported "num_rows" function

    Code:
    function num_rows()
            return mariadb_get_row_count()
    end
    AddFunctionExport("num_rows", num_rows)
    and here are my logs

    server_log.txt

    Code:
    [2019-12-25 15:08:34] [error] [string "vehicles/server/mysql_load.lua"]:11: attempt to compare number with boolean
    line 11 is if(nbrRows > 0) then

    mariadb_log.txt

    Code:
    [2019-12-25 15:10:35.612] [mariadb] [error] mariadb_get_row_count: no active cache ([string "mysql/connect.lua"]:125)
    Last edited by Shidony; 12-25-2019, 04:19 PM.

    #2
    Nobody ?

    Comment


      #3
      Have a look at your mariadb_log.txt file.

      And/ or try:
      Code:
       local query = "SELECT * FROM `vehicles` ORDER BY 'ID' ASC;"

      Comment


        #4
        Thanks for your answer but the problem is not on the SELECT query, it is on the row count. mariadb_get_row_count returns false whatever the query is, although it should return 0 or the number of rows, to clarify it returns a boolean value instead of number.

        Comment


          #5
          Whats the body of `mysql.query` ?

          Comment


            #6
            Code:
            function query(str)
                if not(ping()) then
                    return false
                end
                local result = mariadb_async_query(sql, str)
                return result
            end
            AddFunctionExport("query", query)

            Comment


              #7
              Problem solved, i didn't know that i have to call a function while executing the query to get the row count.

              Comment


                #8
                Get_row_count just returns „false“ if there is an error. ^^

                Comment

                Working...
                X