Querying, Adding, and Editing Data

Ignition offers a number of built-in scripting functions for you to use when running queries against the database. Depending on the type of your query and the sort of results you want, you will use a different function. The following functions are the ones you will use most:

Scripting Function
Description

system.db.runPrepQuery

Use this function to run basic SELECT queries against your database using a special placeholder (?) to allow for dynamic query building.

system.db.runPrepUpdate

Use this function to run queries that change the data in the database. This function also makes use of the (?) placeholder.

system.db.runScalarQuery

Use this function when you want only the value from the first column of the first row of your query to return.

system.db.createSProcCall and
system.db.execSProcCall

Use these functions together to execute any stored procedures you may have in your database.

Note the options provided by each of the different functions. For example, the options that return auto-generated key for insert queries can be extremely helpful and eliminate the need to hit the database multiple times.

You can find examples of each of these functions in their linked topic sections.

In this section ...