Модуль:StrLen: различия между версиями
Материал из GeologyScience Wiki
PatukMI (обсуждение | вклад) |
PatukMI (обсуждение | вклад) |
||
Строка 21: | Строка 21: | ||
end | end | ||
--]] | --]] | ||
local cargo = mw.ext.cargo | |||
function p.Main( frame ) | |||
local tables = 'DS_name' | |||
local fields = 'name=Paper_name, link=Paper_link' | |||
-- 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 = 'table1.fieldE="some value", etc.', | |||
join = 'table1.fieldA = table2.fieldB,table2.fieldC=table3.fieldD, etc.', | |||
groupBy = 'table1.fieldG', | |||
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] | |||
-- Do something with the result table, e.g. result.alias1 | |||
end | |||
--]] | |||
end | |||
return p | return p |
Версия 13:56, 7 сентября 2021
Для документации этого модуля может быть создана страница Модуль:StrLen/doc
local p = {} function p.len( str1 ) local str2 = str1.args[1] local result = '' result = string.len(str2) return result end --[[ function p.req() local result = '' result = mw.ext.externalData.getDbData{ db="DSpace", from="metadatavalue = a,metadatavalue = b", where="a.text_value like '%ARSENOP%' AND a.metadata_field_id = 70 and b.metadata_field_id = 31 and a.dspace_object_id=b.dspace_object_id ", data="Paper_name=a.text_value, Paper_link=a.dspace_object_id" } return result end --]] local cargo = mw.ext.cargo function p.Main( frame ) local tables = 'DS_name' local fields = 'name=Paper_name, link=Paper_link' -- 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 = 'table1.fieldE="some value", etc.', join = 'table1.fieldA = table2.fieldB,table2.fieldC=table3.fieldD, etc.', groupBy = 'table1.fieldG', 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] -- Do something with the result table, e.g. result.alias1 end --]] end return p