QueryValues Helper

The QueryValues Helper file contains a function for writing values or key value pairs of database query results.

Loading this Helper

This helper is loaded using the following code:

rigLoadHelper "queryvalues"

The function:

rigQueryValues(pResult, pKeyValueDelimiter, pRecordDelimiter, pFieldnames)

Parameters

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
put tQuery["fieldnames"] into tFieldNames

# DISPLAY RESULT ARRAY
put rigQueryValues(tResult, , , tFieldNames) into gData["resultData"]

The output looks like this:

ID => 1, Name => Banana Bread, Directions => How to make banana bread.<br />
ID => 2, Name => Pancakes, Directions => How to make pancakes.<br />
ID => 3, Name => Chocolate Cake, Directions => How to make chocolate cake.<br />
ID => 4, Name => Pasta, Directions => How to make pasta.

This example shows how to retrieve the values only:

# 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.