<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="de">
	<id>https://www.verzauberte-welten.de/index.php?action=history&amp;feed=atom&amp;title=Modul%3ACargoUtil%2Fdoc</id>
	<title>Modul:CargoUtil/doc - Versionsgeschichte</title>
	<link rel="self" type="application/atom+xml" href="https://www.verzauberte-welten.de/index.php?action=history&amp;feed=atom&amp;title=Modul%3ACargoUtil%2Fdoc"/>
	<link rel="alternate" type="text/html" href="https://www.verzauberte-welten.de/index.php?title=Modul:CargoUtil/doc&amp;action=history"/>
	<updated>2026-10-28T09:56:14Z</updated>
	<subtitle>Versionsgeschichte dieser Seite in Verzauberte Welten e.V.</subtitle>
	<generator>MediaWiki 1.39.8</generator>
	<entry>
		<id>https://www.verzauberte-welten.de/index.php?title=Modul:CargoUtil/doc&amp;diff=4394&amp;oldid=prev</id>
		<title>imported&gt;Oetterer am 17. Mai 2016 um 10:08 Uhr</title>
		<link rel="alternate" type="text/html" href="https://www.verzauberte-welten.de/index.php?title=Modul:CargoUtil/doc&amp;diff=4394&amp;oldid=prev"/>
		<updated>2016-05-17T10:08:53Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Neue Seite&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{documentation subpage}}&lt;br /&gt;
{{module rating|protected}}&lt;br /&gt;
&amp;lt;!-- Categories go at the bottom of this page and interwikis go in Wikidata. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This module provides serveral useful function that can be used in other module to store or retrive data operating a cargo store.&lt;br /&gt;
&lt;br /&gt;
== Usage ==&lt;br /&gt;
{{code|lang=lua|code=&lt;br /&gt;
local _CARGO = require(&amp;#039;Module:CargoUtil&amp;#039;)&lt;br /&gt;
if dataStore == &amp;#039;cargo&amp;#039; and mw.title.getCurrentTitle().namespace == 10 then&lt;br /&gt;
	-- create table declaration, then call&lt;br /&gt;
	_CARGO.declare(&amp;#039;tablename&amp;#039;, declaration)&lt;br /&gt;
end&lt;br /&gt;
if stash then&lt;br /&gt;
	_CARGO.store(&amp;#039;tablename&amp;#039;, stash)&lt;br /&gt;
end&lt;br /&gt;
local query = {&lt;br /&gt;
	tables = {&amp;#039;table1&amp;#039;}&lt;br /&gt;
	fields = {&amp;#039;_pageName&amp;#039;, &amp;#039;_ID&amp;#039;, &amp;#039;field1&amp;#039;}&lt;br /&gt;
	where = {&amp;#039;field1=&amp;quot;hello world&amp;quot;&amp;#039;, &amp;#039;_ID &amp;gt; 1&amp;#039;}&lt;br /&gt;
	order = {&amp;#039;_ID ASC&amp;#039;, &amp;#039;_pageName DESC&amp;#039;}&lt;br /&gt;
}&lt;br /&gt;
local attributes = {&lt;br /&gt;
	limit = 1&lt;br /&gt;
}&lt;br /&gt;
local result = _CARGO.query(query, attributes)&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Functions ==&lt;br /&gt;
Provided functions are as follow:&lt;br /&gt;
&lt;br /&gt;
=== declare(dbtable, declaration) ===&lt;br /&gt;
Calls #cargo_declare with the provided parameter. Note that this parser function must be called (and therefore placed) on the template page, that later fills the table via [[#store(dbtable, data)|store(dbtable, stash)]]. See [[#Usage|Usage]]-example above. Please refer to the [https://www.mediawiki.org/wiki/Extension:Cargo/Storing_data#Declaring_a_table Cargo documentation page] fore more information about declaration options.&lt;br /&gt;
{{ambox|type=content|text=Warning: The declaration must be done on the template page and cannot be placed inside a &amp;amp;lt;includeonly&amp;amp;gt;-tag because in template space it creates a link in the toolbox (where you can also find &amp;quot;move&amp;quot; and &amp;quot;protect&amp;quot; buttons) to create the table. You have to do this in order to store data.}}&lt;br /&gt;
;dbtable&lt;br /&gt;
:string, mandatory&lt;br /&gt;
:takes the name of the database table that should be declared&lt;br /&gt;
;declaration&lt;br /&gt;
:table or string, mandatory&lt;br /&gt;
:holds the declaration. if provided a table, it must be formatted {{code snippet|lang=lua|code={fieldName : &amp;#039;declaration&amp;#039; } }}&lt;br /&gt;
;return&lt;br /&gt;
:string, return values of the declaration call&lt;br /&gt;
&lt;br /&gt;
=== query(query, attributes, retainBlanks) ===&lt;br /&gt;
Runs a query on the cargo store according to the parameters provided and returns the result as a lua-table. The first parameter (query) has the following mandatory fields:&lt;br /&gt;
;tables&lt;br /&gt;
:table or string, mandatory&lt;br /&gt;
:the name(s) of the table(s) to query data from&lt;br /&gt;
;fields&lt;br /&gt;
:table or string, mandatory&lt;br /&gt;
:the fields, you want to get data from. format is &amp;#039;&amp;#039;fieldname&amp;#039;&amp;#039; or &amp;#039;&amp;#039;fieldname=headline&amp;#039;&amp;#039;. In case of more than one table, please use &amp;#039;&amp;#039;tablename.fieldname&amp;#039;&amp;#039; or &amp;#039;&amp;#039;tablealias.fieldname&amp;#039;&amp;#039;&lt;br /&gt;
;joins&lt;br /&gt;
:table or string, mandatory if you have more than one table. you need one join statement for each table after the first&lt;br /&gt;
:the list of join statements&lt;br /&gt;
Also, there are several optional fields:&lt;br /&gt;
;where&lt;br /&gt;
:table or string, optional&lt;br /&gt;
:you can filter the results with where clauses&lt;br /&gt;
;group&lt;br /&gt;
:table or string, optional&lt;br /&gt;
:the group statements&lt;br /&gt;
;having&lt;br /&gt;
:table or string, optional&lt;br /&gt;
:filter your query, similar to WHERE, but applies to values computed for &amp;quot;groups&amp;quot;&lt;br /&gt;
;order&lt;br /&gt;
:table or string, optional&lt;br /&gt;
:the fields, you wish to sort the result for.  please use &amp;#039;&amp;#039;tablename.fieldname&amp;#039;&amp;#039; or &amp;#039;&amp;#039;tablealias.fieldname&amp;#039;&amp;#039;&lt;br /&gt;
Please keep in mind:&lt;br /&gt;
* attributes may contain any attribute you find in the documentation, but &amp;#039;&amp;#039;intro&amp;#039;&amp;#039; and &amp;#039;&amp;#039;outro&amp;#039;&amp;#039; will be NILed, &amp;#039;&amp;#039;default&amp;#039;&amp;#039; and &amp;#039;&amp;#039;more results text&amp;#039;&amp;#039; will be set to the empty string, and &amp;#039;&amp;#039;format&amp;#039;&amp;#039; will be overwritten&lt;br /&gt;
* per default, does only return fields that contain a value. that can result in an &amp;quot;unbalanced&amp;quot; result, where one row contains more elements than others. if you want to get all fields, set &amp;lt;code&amp;gt;retainBlanks&amp;lt;/code&amp;gt; to true&lt;br /&gt;
;query&lt;br /&gt;
:table, mandatory&lt;br /&gt;
:the arguments to construct the query. see above for details&lt;br /&gt;
;attributes&lt;br /&gt;
:table, optional&lt;br /&gt;
:more attributes, you want to pass on to the query (like limit, for instance)&lt;br /&gt;
;retainBlanks&lt;br /&gt;
:boolean, optional&lt;br /&gt;
:if set to true, result can contain entries with empty values. per default, these entries will be deleted&lt;br /&gt;
;return&lt;br /&gt;
:table, see the following printout as example&lt;br /&gt;
&lt;br /&gt;
The result has the following format:&lt;br /&gt;
&amp;lt;-- cut&lt;br /&gt;
1:&lt;br /&gt;
		1 = &amp;#039;Extension:Cargo&amp;#039;&lt;br /&gt;
		2 = &amp;#039;7&amp;#039;&lt;br /&gt;
		3 = &amp;#039;901&amp;#039;&lt;br /&gt;
		4 = &amp;#039;Cargo provides a lightweight way to store and query the data contained within the calls to templates, such as infoboxes in mysql tables.&amp;#039;&lt;br /&gt;
2:&lt;br /&gt;
		1 = &amp;#039;Extension:SyntaxHighlight GeSHi&amp;#039;&lt;br /&gt;
		2 = &amp;#039;6&amp;#039;&lt;br /&gt;
		3 = &amp;#039;911&amp;#039;&lt;br /&gt;
		4 = &amp;#039;The SyntaxHighlight GeSHi extension provides rich formatting of source code using the &amp;quot;syntaxhighlight&amp;quot;-tag. ...&amp;#039;&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
{{code|lang=lua|code=&lt;br /&gt;
{&lt;br /&gt;
	1 = {&lt;br /&gt;
		id = &amp;#039;7&amp;#039;&lt;br /&gt;
		pageid = &amp;#039;901&amp;#039;&lt;br /&gt;
		description = &amp;#039;Cargo provides a lightweight way to store and query the data contained within the calls to templates, such as infoboxes in mysql tables.&amp;#039;&lt;br /&gt;
		page = &amp;#039;Extension:Cargo&amp;#039;&lt;br /&gt;
	}&lt;br /&gt;
	2 = {&lt;br /&gt;
		id = &amp;#039;6&amp;#039;&lt;br /&gt;
		pageid = &amp;#039;911&amp;#039;&lt;br /&gt;
		description = &amp;#039;The SyntaxHighlight GeSHi extension provides rich formatting of source code using the &amp;quot;syntaxhighlight&amp;quot;-tag. ...&amp;#039;&lt;br /&gt;
		page = &amp;#039;Extension:SyntaxHighlight GeSHi&amp;#039;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
As you can see, the data fields can be indexed either by number or by the provided headline in table &amp;#039;&amp;#039;fields&amp;#039;&amp;#039;. (The headline is either the fieldname or a special string you provided via &amp;#039;&amp;#039;fieldname=headline&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
=== rawquery(query, attributes) ===&lt;br /&gt;
{{ombox|type=content|text=Warning: If you want to do anything other with the result than passing it to the output stream, you have to encapsulate it with {{code snippet|lang=lua|code=mw.text.unstrip()}}, otherwise you only get a strip marker as result!}}&lt;br /&gt;
Calls the parser function #cargo_query according to the provided parameters and passes the result on directly. The format of the output is depending on attributes.format. The first parameter (query) has the following mandatory fields:&lt;br /&gt;
;tables&lt;br /&gt;
:table or string, mandatory&lt;br /&gt;
:the name(s) of the table(s) to query data from&lt;br /&gt;
;fields&lt;br /&gt;
:table or string, mandatory&lt;br /&gt;
:the fields, you want to get data from. format is &amp;#039;&amp;#039;fieldname&amp;#039;&amp;#039; or &amp;#039;&amp;#039;fieldname=headline&amp;#039;&amp;#039;. In case of more than one table, please use &amp;#039;&amp;#039;tablename.fieldname&amp;#039;&amp;#039; or &amp;#039;&amp;#039;tablealias.fieldname&amp;#039;&amp;#039;&lt;br /&gt;
;joins&lt;br /&gt;
:table or string, mandatory if you have more than one table. you need one join statement for each table after the first&lt;br /&gt;
:the list of join statements&lt;br /&gt;
Also, there are several optional fields:&lt;br /&gt;
;where&lt;br /&gt;
:table or string, optional&lt;br /&gt;
:you can filter the results with where clauses&lt;br /&gt;
;group&lt;br /&gt;
:table or string, optional&lt;br /&gt;
:the group statements&lt;br /&gt;
;having&lt;br /&gt;
:table or string, optional&lt;br /&gt;
:filter your query, similar to WHERE, but applies to values computed for &amp;quot;groups&amp;quot;&lt;br /&gt;
;order&lt;br /&gt;
:table or string, optional&lt;br /&gt;
:the fields, you wish to sort the result for.  please use &amp;#039;&amp;#039;tablename.fieldname&amp;#039;&amp;#039; or &amp;#039;&amp;#039;tablealias.fieldname&amp;#039;&amp;#039;&lt;br /&gt;
Please keep in mind:&lt;br /&gt;
* attributes may contain any attribute you find in the documentation, but &amp;#039;&amp;#039;intro&amp;#039;&amp;#039; and &amp;#039;&amp;#039;outro&amp;#039;&amp;#039; will be NILed, &amp;#039;&amp;#039;default&amp;#039;&amp;#039; and &amp;#039;&amp;#039;more results text&amp;#039;&amp;#039; will be set to the empty string, and &amp;#039;&amp;#039;format&amp;#039;&amp;#039; will be overwritten&lt;br /&gt;
* per default, does only return fields that contain a value. that can result in an &amp;quot;unbalanced&amp;quot; result, where one row contains more elements than others. if you want to get all fields, set &amp;lt;code&amp;gt;retainBlanks&amp;lt;/code&amp;gt; to true&lt;br /&gt;
;query&lt;br /&gt;
:table, mandatory&lt;br /&gt;
:the arguments to construct the query. see above for details&lt;br /&gt;
;attributes&lt;br /&gt;
:table, optional&lt;br /&gt;
:more attributes, you want to pass on to the query (like limit, for instance)&lt;br /&gt;
;return&lt;br /&gt;
:string, the renderd output&lt;br /&gt;
&lt;br /&gt;
=== store(dbtable, stash) ===&lt;br /&gt;
Calls #cargo_store with the provided parameters. Note that the table must be [[#declare(dbtable, declaration|declared]] and created before you can actually store anything.&lt;br /&gt;
&lt;br /&gt;
{{ambox|type=info|text=Note: For security reasons, the data stored will be html-encoded. If you manually retrieve data from it (without using any of the query function), you have to decode manually.}}&lt;br /&gt;
&lt;br /&gt;
;dbtable&lt;br /&gt;
:string, mandatory&lt;br /&gt;
:takes the name of the database table to be filled&lt;br /&gt;
;stash&lt;br /&gt;
:table (!), mandatory&lt;br /&gt;
:holds the data to store. it must be formatted {{code snippet|lang=lua|code={fieldName : data of type string or integer } }}&lt;br /&gt;
;return&lt;br /&gt;
:string, return values of the store call&lt;br /&gt;
&lt;br /&gt;
[[Category:Class engine]]&amp;lt;includeonly&amp;gt;{{#ifeq:{{SUBPAGENAME}}|sandbox||&lt;br /&gt;
&amp;lt;!-- Categories go here if you wish an additional category to that set in {{module rating}} above automatically. --&amp;gt;&lt;br /&gt;
[[Category:Lua metamodules]]&lt;br /&gt;
}}&amp;lt;/includeonly&amp;gt;&lt;/div&gt;</summary>
		<author><name>imported&gt;Oetterer</name></author>
	</entry>
</feed>