Parameters are used to store values that can be obtained in applications.
Parameters (Variables) are reusable pieces of information that can be created once and used in multiple places, such as filter conditions, SQL queries, and HTML applications. DbFace store includes a large number of predefined attributes, and also gives you the ability to create your own custom variables.
You can define fixed or dynamic variable(by SQL query or Code) in this section, all variables can be used in all applications.
If you bind a connection to the parameters, these parameters will be only available in applications that using the connection.
Define Global parameters#
Tap the "Parameters" menu to open the "Global Parameters" page.
Create new parameter#
Tap "Create new parameter" button to open the "Create new parameter" dialog. DbFace supports fixed and dynamic parameters.
Fixed Value#
Dynamic Value#
Please notice that DbFace only supports single value. DbFace will execute the SQL query, and make the dynamic value equal the first row and first field value.
If SQL query only return 1 field and 1 row, the column data will treated as the value, other then, the resultset associate array will be the dynamic value.
- TTL
You can specified a TTL (time to live) value for dynamic value, DbFace will refresh the value when the time expired automatically.
If you want to force build the dynamic value, you can click the "Refresh" button at the parameters list page.
Public global parameter#
You can access "Public Global Parameter" in external webpages without having to log in DbFace. Each public paramater has a public URL. i.e.
http://localhost/dbface/user/jsding/value/now
You can load the value in your webpage:
$('#span_now').load("http://localhost/dbface/user/jsding/value/now");
Edit Global Parameter#
Tap the "Edit" button to open the "Update Parameter" dialog. In the dialog, you can edit the parameter settings.
Remove Global Parameter#
Tap the "Delete" button to remove the global parameters.
Refresh Dynamic Parameter Value#
You can tap the "Refresh" button to force DbFace to refresh dynamic parameter value. Since fixed value never changes, this function is not available for "Fixed Parameter".
Use Global parameters#
You use "Global Parameter" in DbFace applications just like the form field.
Use dynamic array value#
Predefined Variables#
DbFace also store several predefined variables that you can use directly.
Variable | Value |
_now_ | Current timestamp |
_date_ | Current date (2016-12-08) |
_account_name_ | The current login username |
_account_email | The current login user email |
_today_ | date('Y-m-d') |
_today_minus_7_ | date('Y-m-d', strtotime('-7 days')) |
_today_minus_30_ | date('Y-m-d', strtotime('-30 days')) |
_today_plus_7_ | date('Y-m-d', strtotime('+7 days')) |
_today_plus_30_ | date('Y-m-d', strtotime('+30 days')) |
_first_day_of_month_ | date('Y-m-01') |
You can also predefined variables on on-premises version, open config/config.inc.php and edit predefined_variables entry
$config['predefined_variables'] = array(
'status_deleted' => 100
);
You might also want to define dynamic predefined variables in hooks.php, find api_get_predefined_variables function in config/hooks.php