Retrieve Records from the Database Using SQL Record Objects
You can use SQL Record objects to quickly find records in the database by using sqlrecord_find.
Create SQL Record Object By Searching (Example 1)
sqlrecord_find allows you to find records in a particular table in the database. The 2nd parameter is what defines the search conditions. You can pass in an integer in which case the primary key field of the table is searched and a single record is returned.
## Look for a lessons record that has an 'id' of 1 (id is the primary key field).
## Store the found SQL Record object in theRecordA.
## If no records are returned then the keys of theRecordA will be empty.
sqlrecord_find "lessons", 1, theRecordA
Create SQL Record Object By Searching (Example 2)
For more advanced searches you can pass in an array that contains any properties that you can set on a SQL Query object.
## Advanced search using a parameters array
## Store the found SQL Record(s) in theRecordsA as a numerically indexed array.
put "id is in :1" into theParamsA["conditions"]
put "1,2" into theParamsA["condition bindings"]
put "id ASC" into theParamsA["order by"]
sqlrecord_find "lessons", theParamsA, theRecordsA