Table
Table schema
Table schema
Get Customer table:
$Table = $this->get('table', 'customer');
Show customer table info
$Table = $this->get('table', 'customer');
$Header = $this->get('ui','header',Array(
'icon' => $Table->getIcon(),
'title' => $Table->getTitle(),
'description' => $Table->getDescription()
)):
List all fields in table
$List = $this->get('ui', 'list');
foreach ( $this->get('table', 'customer')->getFields() as $Field ){
$List->addItem(Array(
'icon' => $Field->getIcon(),
'title' => $Field->getTitle(),
'description' => $Field->getDescription()
));
}
Total number of products ordered in given date:
SELECT
client.name as client,
COUNT(order.nr) as orders,
SUM(order_row.total) as total,
order_sivu.otsikko as order_title
FROM
{$Order->getTblClause()}
{$Order->getTblJoinClause('client')}
{$Order->getTblJoinClause('order_rows.product')}
{$Order->getTblCacheJoinClause()}
WHERE
order.date = '2021-12-15'
GROUP BY
client.nr, product.nr
Method | Return type | Description |
---|---|---|
getId() | int | Unique ID -number. |
getName() | string | Technical name. |
getTitle() | string | Visible name. |
getIcon() | string | Icon name: icon.png. |
getIconUrl() | string | Icon url. |
getColor() | string | Table color. |
getDescription() | string | Longer description. |
getDocumentation() | string | Documentation text. |
getPreferences() | array | Table preferences. |
getPreference($name) | mixed | Table preference by given name. |
getPrivilege() | string | Users table privilege. |
isPrivilege($level) | bool | Return TRUE, if user has privilege of given level: read, add, write, edit. |
Method | Return type | Description |
---|---|---|
refreshCache([$param]) | this | Update table cache information: title, thumbnail, keyword, deleted, style |
Decorators are subclasses that add functionality to the table.
Method | Return type | Description |
---|---|---|
getDecorator(name) | eTableDecorator | Load table decorator object. |
Helper functions to form SQL clauses to the table.
Method | Return type | Description |
---|---|---|
getTbl() | string | DB table name. |
getUserTbl() | string | DB table name for user view. |
getWhere() | string | SQL FROM -clause for this table |
getLeftJoin($table) | string | SQL LEFT JOIN -clause to this table for given table. |
getTblJoinClause($field[,$alias,$on]) | string | Return SQL join clause: LEFT JOIN fieldTable->targetTable. Alias default: table name. |
getTblCacheJoinClause() | string | Return SQL join caluse: LEFT JOIN cache_table (page title, description, color, searchwords...) |
Method | Return type | Description |
---|---|---|
isField($name) | bool | Return TRUE, if table has given field. |
getField($name) | Field | Return Field -object for given field. |
getFieldByRole(name) | Field[] | Get Field that implements given role. (date..) |
getFieldNames() | array | Get list of field names in table. |
getReferenceFields() | array[] | Get list of fields that refer to this table. |
getFields() | Field[] | Get Field objects |
getFieldsByType(type[,type..]) | Field[] | Get Fields of given type. |
getFieldsByUse(use) | Field[] | Get Fields that implement given use. (date, location..) |
getEditableFields() | Field[] | Get Field objects oh fields that can be edited by user. (privilege, not fixed) |
These functions are used by Pages and Page, which is preferred way of fetching data. These functions, however, can be used to get raw data in more efficient manner.
Method | Return type | Description |
---|---|---|
getRow($id) | array | Get given row in table. (Raw data). |
getRows($clause) | array[] | Get multiple rows in table. |
getRowWhereField($where) | array | Get single row that matches given parameters. |
getRowTitle($id) | string | Get title text for given row. |
getRowIcon($id) | string | Get icon name for given row. |
getRowStyle($id) | string | Get style name (color) for given row. |
getValue($id,$field) | string | Get value of field in given row. |
clear() | - | Clear all data from table. |
Get Page -object from table:
Method | Return type | Description |
---|---|---|
getPage($id) | Page | Get given page in table. |
newPage() | Page | Create new record to table. |
findPage($values) | Page | Return page that matches given field=>value pair. |
findUniquePage($values) | Page | Return page that matches given field=>value pair. If page is not found, set field values to the new object. |
findPages($values) | Pages | Return pages that matches given field=>value pair. |