Creating A SQL Query Object
SQL Query objects are arrays that represent a pseudo object. This object defines what a database query will do. You create a SQL Query object by passing the name of a table to sqlquery_create. SQL Queries are not stored anywhere but are stored in temporary variables.
Create A SQL Query Object
put sqlquery_createObject("lessons") into theQueryA
Set Search Conditions
You can specify the WHERE condition of a query by setting the "conditions" property. You can even use english words rather such as "contains":
put the text of field "SearchCriteria" into theUserSearchString
sqlquery_set theQueryA, "conditions", "lessons.title contains ':1'", theUserSearchString
Set Sorting Field
sqlquery_set theQueryA "order by", "lessons.title"
Get Data From A SQL Query Object
Use any of the following to retrieve data from a SQL Query object. You can get data as an array, raw data or as records. The second parameter to each command is passed by reference and will contain the data from your database after the call has completed.
If you don't know what records are yet don't worry. That will be covered later.
sqlquery_retrieveAsArray theQueryA, theArrayA
put the result into theError
sqlquery_retrieveAsData theQueryA, theData
put the result into theError
sqlquery_retrieveAsRecords theQueryA, theRecordsA
put the result into theError
For further information see the documentation for sqlquery_retrieveAsArray, sqlquery_retrieveAsData and sqlquery_retrieveAsRecords.
0 Comments
Add your comment