QueryValues Plugin
The QueryValues Plugin file contains a function for writing values or key value pairs of database query results.
Loading this Plugin
This plugin is loaded using the following code:
rigLoadPlugin "queryvalues"
The function:
rigQueryValues(pResult, pKeyValueDelimiter, pRecordDelimiter)
The first parameter is a database query result. The second parameter defines the key value delimiter (default is " => "). The third parameter defines the record delimiter (default is ", "). If you leave the second and third parameters blank the default values are used. "<>" as the second parameter specifies, that you want to omit the array keys and retrieve the values only. Example:
# MODEL DATABASE QUERY
put mymodelFetchAllData("recipe") into tQuery
put tQuery["resultarray"] into tResult
# DISPLAY RESULT ARRAY
put rigQueryValues(tResult) into gData["resultData"]
The output looks like this:
1 => 1, 2 => Banana Bread, 3 => How to make banana bread.<br />
1 => 2, 2 => Pancakes, 3 => How to make pancakes.<br />
1 => 3, 2 => Chocolate Cake, 3 => How to make chocolate cake.<br />
1 => 4, 2 => Pasta, 3 => How to make pasta.
Here is another example:
# MODEL DATABASE QUERY
put mymodelFetchAllData("recipe") into tQuery
put tQuery["resultarray"] into tResult
# DISPLAY RESULT ARRAY
put "<>" into tKeyValueDelim
put " - " into tRecordDelim
put rigQueryValues(tResult, tKeyValueDelim, tRecordDelim) into gData["resultData"]
The output looks like this:
1 - Banana Bread - How to make banana bread.<br />
2 - Pancakes - How to make pancakes.<br />
3 - Chocolate Cake - How to make chocolate cake.<br />
4 - Pasta - How to make pasta.