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) 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.

Open global parameters page in DbFace

Create new parameter#

Tap "Create new parameter" button to open the "Create new parameter" dialog. DbFace supports fixed and dynamic parameters.

Fixed Value#

Global parameters in DbFace

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. Global parameters in DbFace

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.

Edit global parameter in DbFace

Remove Global Parameter#

Tap the "Delete" button to remove the global parameters.

Remove global parameter in DbFace

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". Refresh parameter value in DbFace

Use Global parameters#

You use "Global Parameter" in DbFace applications just like the form field.

simple sample that use global parameter in DbFace

Use dynamic array value#

Use dynamic array variables in DbFace

Predefined Variables#

DbFace also store several predefined variables that you can use directly.

VariableValue
_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