DATA Methods

fetch()

Create SQL select statement and join parent table. With tables that have been imported into the system the function will automatically include the default ORDER BY field defined in the backend's database section. The parent table also needs to be defined in the backend's database section and will be joined by LEFT OUTER join.

string fetch( string table [, array table_fields [, string table_where [, string table_order [, string table_group [, array parent_fields [, string parent_where [, string parent_order ]]]]]]])

Return

SQL statement.

Parameter
Description
tableThe table name.
table_fieldsFields to be selected. If left empty, all fields will be selected.
table_whereSQL WHERE statement.
table_orderSQL - ORDER BY field(s)
table_groupSQL - GROUP BY statement.
parent_fieldsFields of parent table to be selected.
parent_whereSQL WHERE statement to be applied to parent table.
parent_orderSQL - ORDER BY statement on parent table.

Create SQL select for imported table

$DATA->sql("data_api_object")
RETURN: 'SELECT `data_api_object`.* FROM `data_api_object` ORDER BY `data_api_object`.`object` ASC,`data_api_object`.`ID_API_OBJECT`'

Create SQL select for any table

$DATA->sql("data_test")
RETURN: 'SELECT `data_test`.* FROM `data_test`'

Create SQL statement including parent table

$DATA->sql("data_api_method", false, false, false, false, array("object", "systemfile"), "ID_API_OBJECT = 1", "object ASC")
RETURN: 'SELECT `data_api_method`.*,`data_api_object`.`object`,`data_api_object`.`systemfile` FROM `data_api_method` LEFT OUTER JOIN `data_api_object` ON (`data_api_method`.`ID_API_OBJECT` = `data_api_object`.`ID_API_OBJECT`) WHERE (`data_api_object`.`ID_API_OBJECT` = 1) ORDER BY `data_api_object`.`object` ASC,`data_api_object`.`ID_API_OBJECT`,`data_api_method`.`method` ASC,`data_api_method`.`ID_API_METHOD`'