Overview

You can code directly against the Data Storage engine driver for lower level access. This is not normally recommended and shouldn't be needed for most applications.

Data Storage

ActiveWAFL uses Data Storage drivers, which abstract the communication with multiple data storage engines (such as MySql).

The default ActiveWAFL Storage Engine driver is for MySql 5.2+.
Application objects expose the methods GetStorageEngine and GetStorageEngines which can be used to get the connected data storage instances for the given application.

Get Table Data

GetData
  1. $storageEngine->GetData($storageLocation, $keyFieldName, $keyValue);
The meanings of the arguments are Storage Engine specific. However, for most Storage Engine drivers, including MySql, the following applies:
$storageLocation
The name of the table you want to get data from.
$keyFieldName
The name of the column you are searching against (usually a primary key).
$keyValue
The value that the $keyFieldName must match to return the row.
GetDataGroup
  1. $storageEngine->GetDataGroup($storageLocation, $filter, $orderByFieldName, $maxRecordCount, $filterJoinLocations, $startOffset);
$storageLocation
The name of the table you want to get data from.
$filter
Sql "Where" claus.e
$orderByFieldName
Sql "Order By" clause.
$maxRecordCount
The max number of rows to return.
$filterJoinLocations
an array keyed by table names that are to be joined. The element values represent the column name that the tables will be joined on.
$startOffset
Which row number to start at.

Store Table Data

StoreData
  1. $storageEngine->StoreData($storageLocation, $fieldNames, $fieldValues, $keyFieldName, $keyValueIsAutoGenerated);
$storageLocation
The name of the table you want to store data on.
$fieldNames
An array of the name of the fields to set the values for.
$fieldValues
An array of the values to set the columns in $fieldNames to.
$keyFieldName
The name of the primary key column.
$keyValueIsAutoGenerated
Whether or not the value of the primary key column is generated automatically.

Get Aggregate Data

Get average, count, and sum
  1. $avg = $storageEngine->GetDataGroupAvg($storageLocation, $columnName);
  2. $count = $storageEngine->GetDataGroupCount($storageLocation, $columnName);
  3. $sum = $storageEngine->GetDataGroupSum($storageLocation, $columnName);
$storageLocation
The name of the table you want to get data from.
$columnName
The name of the column to aggregate.

Direct SQL Queries

DirectExecute, DirectQuery
  1. $storageEngine->DirectExecute($sql) //execute a sql query that returns no rows
  2. $storageEngine->DirectQuery($sql) //execute a sql query that returns rows

Escaping Data

Escape data prior to inserting it to ensure data integrity and security.
Escape user input string in a Controller action
  1. $formVar = storageEngine->Escape($request->GetInputString("FormFieldName"));

Data Joins

GetDataGroup
  1. $storageEngine->GetDataGroup($storageLocation, $filter, $orderByFieldName, $maxRecordCount, $filterJoinLocations, $startOffset)
$filterJoinLocations format
$joinObjects is an array keyed by the names of the tables you wish to join. The element value is the name of the column you wish to join on.
filterJoinLocations example
  1. $filterJoinLocations=array("EmployeeDepartments"=>"EmployeeId", "EmployeeDistricts"=>"EmployeeId");