Template:Query

From Irony Wiki
Jump to navigation Jump to search
Error: Table null not found.

Documentation

This template does a simple query for data from a Cargo table. It returns data from one column of one table, by filtering one other column. This is all that is needed for many of the uses of Cargo on this wiki, but for more complex uses, you'll need to use the Cargo functions directly.

Usage[edit source]

Basic usage:

{{query|table=table|get=column to output data from|from=name or ID}}

or

{{query|table=table|get=column to output data from|filter_col=column to filter|filter_col_val=value to filter by}}

  • |table= - The Cargo table to search in. Go to Special:CargoTables to see all tables.
  • |get= - The table column from which data should be retrieved and output.
  • |from= - If this parameter is a valid Discord ID (e.g. 501310750074077215), then data will only be taken from table rows whose "id" column matches this parameter. If this parameter is not a valid Discord ID, then the "name" column will be searched instead. If these columns are not present in the table, or you just want to filter by a different column, then use these parameters instead:
    • |filter_col= - The column to search. If using this parameter, you must also specify the filter_col_val parameter.
    • |filter_col_val= - The value to search for in the column specified in filter_col.

Not all parameters were listed here. For a detailed description of all parameters, see the TemplateData section below.

Examples[edit source]

If you want to output the owner of Whenthe, you could use either {{query|table=discord_servers|get=owner|from=Whenthe}} or {{query|table=discord_servers|get=owner|from=501310750074077215}}, which would output: steely21

If you wanted a list of active servers, you could do something like {{query|table=discord_servers|get=name|filter_col=status|filter_col_val=active|limit=25}}, which would output: 69SwagBalls420, 69SwagBalls420 Cord, Arabfunny III, Bruhmoment, Can win with great friends, CATS IN A TUXEDO, Dogelore, Dogelore Refugee Ark, 𝓓𝓕𝓜, Gay Spider Brothel, Gondal: From The Ashes, House of Bingus, I.C.U., iorny heaven CHAPTER 3, Irony Server Wiki Discord, Latvian OKBR, OkBhaiBudbak, OkBuddyChicanery, okbuddyhololive, OkBuddyPHD, OkKolegaUposledzony, OkKolegaUposledzony/en, OKPR Discord, OKPR Discord, OKPR Discord

TemplateData[edit source]

Does a simple query for data from a Cargo table. It returns data from one column of one table, by filtering one other column.

Template parameters[Edit template data]

ParameterDescriptionTypeStatus
Tabletable

The Cargo table to search in. Go to [[Special:CargoTables]] to see all tables.

Example
discord_servers
Stringrequired
Field to displayget

The table column from which data should be retrieved and output. For example, if you wanted to find and output Whenthe's status, you would put the "status" column here.

Example
status
Stringrequired
Fromfrom

Filters results by name or ID. If this is in the format of a Discord ID, then only results whose "id" column matches this parameter will be used. Otherwise, only results whose "name" column matches this parameter will be used. For example, if you wanted to find and output Whenthe's status, you would put Whenthe's name or ID here. If there's a different column you want to filter by, you can use the filter_col and filter_col_val parameters instead.

Example
Whenthe
Stringsuggested
filter_colfilter_col

The table column that contains the values you want to filter. If using this parameter, the "from" parameter will be ignored, and you MUST also use the filter_col_by parameter.

Example
name
Stringoptional
filter_col_valfilter_col_val

The value you're searching for from the column defined in the filter_col parameter. Only the data from rows that match this value in the column will be used. This parameter has no effect if filter_col is not defined.

Example
Whenthe
Stringoptional
limitlimit

The maximum number of results to get. Many queries only have one result. If there is more, and this parameter is set to a number greater than the default 1, the results will be output in a comma-delimited list.

Default
1
Numberoptional
defaultdefault

What to output if no results are found.

Default
(empty string)
Stringoptional
has_htmlhas_html

Set this to "yes" if the output you want contains HTML that you want to use.

Booleanoptional