33 lines
1.7 KiB
Markdown
33 lines
1.7 KiB
Markdown
## ormAccessSelect()
|
|
|
|
The `ormAccessSelect()` command retrieves records from a table in a database based on the provided selection criteria. This command selects the desired fields and stores the results in a target variable.
|
|
|
|
### Parameters
|
|
|
|
* fields Type: `variable` Description: A string containing the names of the fields to be retrieved. The field names should be separated by commas.
|
|
* dbase Type: `variable` Description: The name of the database from which records should be retrieved. It must be a variable containing the name of the database.
|
|
* selector Type: `variable` Description: A condition to select the records to be retrieved. It must be a string specifying the selection criteria in SQL format, such as `id = 1` .
|
|
* varTarget Type: `variable` Description: The variable in which the query results will be stored. It must be a variable that will receive a list of dictionaries, each representing a retrieved record.
|
|
|
|
### Command Flow
|
|
|
|
### Example Usage
|
|
|
|
Suppose you want to retrieve the `username` field for all users where `age` is greater than 25 from a database called `myDatabase` .
|
|
|
|
```javascript
|
|
// Define variables
|
|
fields = "username"
|
|
dbase = "myDatabase"
|
|
selector = "age > 25"
|
|
usersList = ''
|
|
|
|
// Call the command to retrieve the records
|
|
ormAccessSelect(fields, dbase, selector, usersList)
|
|
|
|
// Return the query results via addResult
|
|
addResult(usersList)
|
|
```
|
|
|
|
In this example, the `ormAccessSelect()` command will retrieve the `username` field for all users in the `myDatabase` database where `age` is greater than 25. The results will be stored in the `usersList` variable, and this variable will be returned via `addResult(usersList)` . The output will be a list of dictionaries, each representing a user whose username has been retrieved.
|