1.8 KiB
1.8 KiB
ormCreateTable()
The ormCreateTable() command creates a new table in a database using the specified ORM (Object-Relational Mapping). This command defines the columns of the table and their data types, and stores a reference to the created table in a destination variable.
Parameters
- fields Type: value Description: A string containing the names of the table columns, separated by commas. Each column name should correspond to a field in the table.
- fieldsType Type: value Description: A string containing the data types for each column, separated by commas. The data types should be in the same order as the column names in fields .
- dbaseName Type: value Description: The name of the database where the table will be created. It should be a string indicating the target database.
- varTarget Type: variable Description: The variable in which the reference to the created table will be stored. It should be a variable that will receive the reference to the new table.
Command Flow
Example Usage
Suppose you want to create a table called users in a database called myDatabase, with two columns: username of type VARCHAR and age of type INTEGER.
// Define variables
fields = "username,age"
fieldsType = "VARCHAR,INTEGER"
dbaseName = "myDatabase"
tableReference = ''
// Call the command to create the table
ormCreateTable(fields, fieldsType, dbaseName, tableReference)
// Return the reference to the created table via addResult
addResult(tableReference)
In this example, the ormCreateTable() command will create a table in the myDatabase database with the specified columns and data types. The reference to the new table will be stored in the tableReference variable, and this variable will be returned via addResult(tableReference). The output will include the reference to the created table.