mNo edit summary
mNo edit summary
Line 20: Line 20:
     for r = 1, #results do
     for r = 1, #results do
         local result = results[r]
         local result = results[r]
         table.insert(t, result.Commendation .. " = " .. result.cnt)
         table.insert(t, result.Commendation .. " = " .. result["COUNT(*)"])
     end
     end
     return table.concat(t, '<br>')
     return table.concat(t, '<br>')

Revision as of 19:33, 8 November 2022

Documentation for this module may be created at Module:Commendations/doc

local p = {}
local cargo = mw.ext.cargo

function p.Main( frame )
    local t = {}
    local tables = 'Commendations'
    local fields = 'Commendation, COUNT(*)'
    -- optional parameters are grouped in one table
    -- you can omit any or all of them, except join if you use more than one table
    local args = {
        --where = '',
        --join = 'table1.fieldA = table2.fieldB,table2.fieldC=table3.fieldD, etc.',
        groupBy = 'Commendation',
        --having = 'table1.fieldG="some value", etc.',
        --orderBy = 'table2.fieldF, etc.',
        --limit = some number,
        --offset = some number,
    }
    local results = cargo.query( tables, fields, args )
    for r = 1, #results do
        local result = results[r]
        table.insert(t, result.Commendation .. " = " .. result["COUNT(*)"])
    end
    return table.concat(t, '<br>')
end

return p


Categories: