how to create data modules
The main data modules are views and forms reference
Views output data in a table format.
Forms consist of controls and are input and output.
For the data modules:
i. the application must connect to a database. how to
ii. users must be created with permissions to them. how to
1. login
a. Log in the app designer designer.mydbapp.com
2. create a view
a. Navigate to data > views
b. Click the new button to create a view.
c. In the view textbox enter the name of the view.
d. In the sql textbox enter the SQL query of the view with placeholders for the parameters.
eg. $(id), $(name), $(surname), $(type), $(phone) and $(email) are parameter placeholders reference
Note that all the parameters are enclosed in single quotes '
'$(id)' = '', '$(name)' = '', etc. will match all rows when the parameters are not specified.
SELECT `name`, `surname`, `type`, `phone`, `email`, `id`
FROM `contact`
WHERE ('$(id)' = '' OR `id` = '$(id)')
AND ('$(name)' = '' OR `name` LIKE '%$(name)%')
AND ('$(surname)' = '' OR `surname` LIKE '%$(surname)%')
AND ('$(type)' = '' OR `type` = '$(type)')
AND ('$(phone)' = '' OR `phone` LIKE '%$(phone)%')
AND ('$(email)' = '' OR `email` LIKE '%$(email)%')
ORDER BY `name`, `surname`;
e. In the columns textbox enter the number of visible columns, 0 indicates all.
f. Click save to save it.
3. add parameters to the view
a. Click the parameters… cell next to the view.
b. Click the new button to create a parameter.
c. Fillin as follows:
sort - the sort index of the parameter
parameter - the name of the parameter eg. id, name, surname, type, phone, email
type, etc. refer to parameters reference
d. Click save to save it.
e. Repeat step b to d for each parameter.
f. Click back to go back to the views.
3. add columns to the view
Note: it is not necessary to define all the columns of a view, however to change the defaults of a column it must be defined.
a. Click the columns… cell next to the view.
b. Click the new button to create a column.
c. Fillin as follows:
column - the name of the column as returned by the SQL query.
align - the vertical alignment of the column, blank indicates default.
html - indicates that the column output is html (xcode), otherwise applicable characters are converted to html entities.
href - href link for the column eg. form?form=contact&id=$(id)&back=$(__uri)
where $(id) is place holder for the id column in the view
and $(__uri) is place holder for the current url.
all the view's returned columns can be used.
d. Click save to save it.
e. Repeat step b to d for each parameter.
f. Click back to go back to the views.
4. add actions to the view
a. Click the actions… cell next to the view.
b. Click the new button to create an action.
c. Fillin as follows:
sort - the sort index of the action
action - the name of the action eg. new, delete
type - HREF or SCRIPT
href - in the case of type HREF, href link for the action eg. form?form=contact&back=$(__uri)&insert
where $(__uri) is a placeholder of the current url. all the view parameters can be used.
script - in the case of type SCRIPT, xcode script of the action. refer to xcode reference
eg. $(id) is a placeholders. all the view parameters and view columns can be used, for view parameters get_ must be prepended eg. $(get_name) reference
<!--?
DELETE FROM `contact`
WHERE `id` = '$(id)';
--><!--/?-->
5. create a form
Note: forms operate in 2 modes, insert and update, insert is indicated in the query string otherwise update.
a. Navigate to data > forms
b. Click the new button to create a form.
c. In the newdata sql textbox, enter the sql used in insert mode to populate the columns with default values.
eg. all form parameters can be used as placeholders reference
d. In the update sql textbox, enter the sql used in update mode to populate the columns.
eg. $(id) is a placeholder. all form parameters can be used.
SELECT *
FROM `contact`
WHERE `id` = '$(id)';
6. add parameters to the form
a. Click the parameters… cell next to the form.
b. Click the new button to create a parameter.
c. Fillin as follows:
parameter - the name of the parameter eg. id, back
type, etc. refer to parameters reference
d. Click save to save it.
e. Repeat step b to d for each parameter.
f. Click back to go back to the forms.
7. add columns to the form
Note:Unlike in a view, it is necessary to define all the columns of a form.
a. Click the columns… cell next to the form.
b. Click the new button to create a column.
c. Fillin as follows:
sort - the sort index of the column
parameter - the name of the column eg. name, surname, type, phone, email
type, etc. refer to parameters reference
d. Click save to save it.
e. Repeat step b to d for each column.
f. Click back to go back to the forms.
8. add actions to the form
a. Click the actions… cell next to the view.
b. Click the new button to create an action.
c. Fillin as follows:
sort - the sort index of the action
action - the name of the action eg. save, cancel
type - HREF or SCRIPT
href - in the case of type HREF, href link for the action eg. view?view=order&customer=$(customer)
where $(customer) is a placeholder. all the form parameters can be used.
insert script - in the case of type SCRIPT, xcode script of the action when form is in insert mode. refer to xcode reference
eg. $(name), $(surname), $(type), $(phone), $(email) are placeholders reference
all the form parameters and form columns can be used, for form parameters get_ must be prepended
<!--?
INSERT INTO `contact`
SET
`name` = '$(name)',
`surname` = '$(surname)',
`type` = '$(type)',
`phone` = '$(phone)',
`email` = '$(email)';
--><!--/?-->
<!--?SELECT LAST_INSERT_ID() `id`;--><!--/?-->
<!--LET:_OUT.redirect:url_fillin('view?view=contact&id=$(id)&search')-->
update script - in the case of type SCRIPT, xcode script of the action when form is in update mode. refer to xcode reference
eg. $(name), $(surname), $(type), $(phone), $(email), $(get_id) and $[get_back] are placeholders reference
all the form parameters and form columns can be used, for form parameters get_ must be prepended eg. $(get_id), $[get_back]
<!--?
UPDATE `contact`
SET
`name` = '$(name)',
`surname` = '$(surname)',
`type` = '$(type)',
`phone` = '$(phone)',
`email` = '$(email)'
WHERE `id` = '$(get_id)';
--><!--/?-->
<!--LET:_OUT.redirect:url_fillin('$[get_back]')-->
gui

Matthew