This the multi-page printable view of this section. Click here to print.

Return to the regular view of this page.

Coding

DbFace allows you creating your own API by PHP for public access. DbFace use CodeIgniter Framework to provide a flexible PHP development environment.

Create or edit Cloud code

  • Sign in DbFace with Administrator or Developer account
  • Tap “Settings” -> “Cloud Code”

You will see all available cloud code you already created in the selected database connection.

Cloud code list page

Tap the “Create API Code” button to create a new API code.

Cloud code list page

  • API Name: this will be the Public URL for accessing the cloud
  • Disabled: if you want disable the public URL temporarily, you can check the “Disable” checkbox
  • Open: open the cloud code in debug mode
  • Save Changes: after editing the cloud code, do not forget click “Save Changes” button to save the cloud code

Access Cloud Code

You will find the cloud code public URL in the list page.

Get Cloud code public URL

Cloud Code Alerts

Cloud Code Alerts can be configured to run either on an interval or at a scheduled time.

To run a Cloud Code Alert on an interval, select the interval option and choose from every 10 minutes, 30 minutes, 1 hours, 4 hours, 12 hours, or 24 hours. Run cloud code alert on an interval

By selecting the ‘Schedule’ option, cloud code alerts can be set to run at a specific time in specific timezone.
Run cloud code alert on an schedule You can change the timezone at config/config.inc.php file

$config['crontab_schedule_timezone'] = date_default_timezone_get();

You can find all the available timezone here.

Enable Cloud Code Alerts

You need to enable crontab to enable Cloud Code Alerts feature.

php index.php crontab crontab_key

The crontab_key can be found in config/config.inc.php

$config['crontab_execution_key'] = '6193rW3iTjXo7N3S27t2I2GA6OJjo03S';

Please modify the default crontab_execution_key, or other people can invoke the crontab if they know your dbface installation URL.

We recommend you run the cron application every 10 minutes.

sudo crontab -e

add

*/10 * * * * php /var/www/dbface/index.php cron 6193rW3iTjXo7N3S27t2I2GA6OJjo03S

Disabling Cloud Code Alerts

Cloud Code Alerts can be disabled by turning off the “Enable Alerts” switch under the Cloud Code footer.
Disable cloud code alert

!!! tip “Please Notice” Cloud Code only be available on On-premises installation or Enterprise plan.

Templates

You can also create your own Smarty templates that can be used in Cloud Code or PHP Report. Create templates

!!! tip “Please Notice” Use {$ and } in templates. We already put predefined variables, parameters and other global variables into the smarty instance.

Use templates in Cloud Codes

We already create $smarty variable and put all available variables into the smarty instance. You can also use $db variable that point to your current database connection.

$smarty->display('my-template.tpl');

Use templates in PHP reports

$smarty->display('my-template.tpl');

Scheduled Jobs

Scheduled Jobs As default, All scheduled jobs are executed by 10 minutes. You can drag the “Drag” icon to order the scheduled jobs.

Triggers

Edit Triggers

Edit Triggers Functions

User Login

/**
 * Trigger function when user sign in DbFace successfully.
 *
 * @param $params
 *
 * @return bool
 */
function _trigger_login($params) {
  return TRUE;
}

Pre Application

/**
 * trigger function before user execute an application
 *
 * @param $params: appid, creatorid, userid
 */
function _trigger_pre_application($params) {
  return TRUE;
}

Post Application

/**
 * trigger function after user execute an application
 *
 * @param $params: appid, creatorid, userid
 */
function _trigger_post_application($params) {
  return FALSE;
}

Custom Menu for Viewers

You can define custom menu for viewers in DbFace by an editable YAML file.

DbFace Modules

DbFace modules are pure php applications that be able to installed in DbFace. You can install DbFace modules as DbFace menu items. So we can access these php applications in DbFace navigation system.

1 - Auto Load Code

Auto Load Code.

DbFace will load all auto load code globally. So all functions defined in auto load code will available in all scripts.

We can define auto load code and use the php function in them in Parameters, then use them in DbFace application or create elastic dashboard widgets.

2 - Coding workspace

DbFace Coding Workspace

DbFace integrates full featured PHP project editor that you can define cloud code directly using web browser.

To open the IDE, click Settings, tap Cloud Code menu item, and find the “Start Development Workspace” button, Open DbFace Coding Workspace

the IDE will open. DbFace Coding Workspace

3 - FAQs

DbFace Coding FAQs.

DbFace Coding FAQs

DbFace provides many internal PHP and javascript functions to help you access the features, we list functions that you can use in your PHP or HTML report here:

PHP Functions

You can use PHP functions in PHP reports or Cloud Code.

import_var

PHP function to get global parameters value created in DbFace

<?php
  // get all global parameters created in DbFace
  $vars = import_var();

  // get total lost user value 
  $var = import_var('total_lost_user');
?>

import_db

PHP function to get database connection object to specific connection

  $db = import_db('Clash_of_rome');

call_http_service($url, $params = array(), $method = “POST”, $ignore_error = FALSE)

PHP function to get remote http response body

  $result = call_http_service('https://www.dbface.com');

Javascript Functions

4 - Insights

Insights

Smart Insights! Analyzes your data and automatically generates multiple dbface applications.

We are working hard on this section. It is coming soon!

5 - Jobs

Jobs.

Jobs

There is no background job functionality in DbFace. If you have scheduled jobs, port them over to a system cron job.

*/10 * * * * php /your-dbface-installation-directory/index.php cron your-cron-job-key >> /your-dbface-installation-directory/user/logs/cronlog.log

You will find your-cron-job-key in config/config.inc.php.

// crontab execution key
$config['crontab_execution_key'] = 'your-cronjob-execution-key';

Please consider to change this value for security reason.

6 - Managed DbFace

Managed DbFace.

Managed DbFace

With Managed DbFace, you do not need to care about hosting. We will host the latest DbFace on Amazon AWS for you.

To get your managed DbFace installation.

Open https://www.dbface.com/pricing and subscibe Enterprise version. We will setup your instance in 24 hours.

Your installation URL should be https://apps.dbface.com/[your-payment-name]. To use your own domain for the DbFace installation, please open a new ticket at our ticket system.

7 - Query Builder

Query Builder.

Query builder helps you generate complex SQL query without direct coding work.

It takes just a few clicks to add conditions and build the query. No complex SQL constructs to deal with - just a visual interface that looks like a human language sentence.

Query builder tool in DbFace

You can open DbFace Query Builder in the following page:

  • Tap the “Query Builder” button in SQL Workshop
    Open Query Builder tool in SQL Workshop

  • Tap the “Query Builder” button in the application builder page.
    Open Query Builder tool in Application Builder Page

8 - Query Stats

Query Stats.

Query Stats

Query stats page shows you the latest queries and queries performance. Click Settings, tap Query Stats, DbFace will go to this page. DbFace Query Stats

  • Start Time
    The query start time

  • Query
    The query statement, if the statement is too long, click the icon to display the whole statement

  • Elapse(s)
    Seconds to get the query result. We can use check this field to get bottlelack of the application.

9 - Remote API Monitor

Remote API Monitor.

We are working hard on this section. It is coming soon!

10 - Script Library

As the same as the Form Library, you can also reuse the script queries of other applications using the same database connection.

Script library in DbFace

  • ** Open Script Library**
    Tap the “Script Library” button at the top corner of Application Script Editor will open the Script Library.

  • ** Preview Script**
    At the opened Script Library dialog, Click the “Info” button will highlight the Script Query.

  • Copy Script into the current application
    Double click the Script will paste the selected script query into the application editor.

11 - Snapshots

Snapshots.

Snapshots

Snapshots allow you backup and recover full work in DbFace. To view snapshots files, click Settings and click “Snapshots” menu item. Snapshot in DbFace

You will see all existing snapshots. Snapshot Manager in DbFace

  • Create Snapshot

DbFace will collect all current work in DbFace, and zip them in a zip file. You will find snapshot files in user/snapshots directory.

  • Upload Snapshot

Upload snapshot file into DbFace. You can use the feature to move snapshot file created in other installation into this installation.

  • Download Snapshot

Download the snapshot zip file. We recommend you download import snapshot files and backup in multiple places.

  • Recover Snapshot

Recover DbFace from the snapshot file, DbFace will create snapshot file from current state automatically.

  • Delete Snapshot

Removed the snapshot file.

12 - SQL Terminal

SQL Terminal.

SQL Terminal helps you to execute and test SQL query on the fly. Click the “SQL Terminal” button to open SQL Terminal dialog:

SQL Terminal in DbFace

13 - Story board

Story board.

We are working hard on this section. It is coming soon!

14 - Table Row Action Script

Table Row Action Script

Table Row Action Script

We can use table row action script to add additional buttons for each row of tabular report. Additional Table Row action

Create Table Row Action Button

Create table row action

  • Action button label

  • Application Type

  • Application script when clicking the table row button
    When user click the action button, all columns of the row will pass to the application script.

15 - Notebook

A short lead description about this content page. It can be bold or italic and can be split over multiple paragraphs.

Notebook

We are working hard on this section. It is coming soon!

16 - Optional Script

All DbFace application contains one main script. You can attach more optional scripts in one DbFace application. DbFace will render other scripts in tab. When user click optional script tab, the option script will executed to render the application.

Optional script