Topics
- Introduction 1
- SQL Yoga Primer 3
- Notes on Error Reporting 3
- General Concepts 4
- Database Objects 5
- Database Connections 5
-
SQL Query Objects
6
- Introduction to SQL Query Objects
- Creating A SQL Query Object
- How Do I Create Records In a Database Table Using a SQL Query Object?
- How Do I Delete Records From the Database Table Using a SQL Query Object?
- How To Use Cursors With a SQL Query Object
- How Can I Convert a User Search String Into An AND/OR Search When Generating a Query?
- Record Objects 5
- Table Objects 4
- Table Relationships 3
Other Resources
How-tos
- Lessons
- Signing Your Applications and Building Installers
GLX Application Framework
- GLX Application Framework 1.1
- Converting An Existing Application To Use The Framework
SQL Yoga
- SQL Yoga
- SQL Yoga Examples
- SQL Yoga To-Do Application
- SQL Yoga IDE Plugin
Plugins, Externals and Libraries
- Plugins
Comments
0 for this lesson
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.


Add your comment