Function descriptions Function “new_data()” Estimated reading: 3 minutes mixed new_data(numeric $gtabid, array $relation=null, numeric $copy=null, numeric $version=null, numeric $forceNewID=null); Function to create a new data record (./limbas_src/gtab/gtab.lib). Parameters: $gtabid Valid table ID: Specifies the table in which the new data record will be created. Invalid table ID: This function call has no effect. $relation Zero, invalid values: The new data record is not linked to another table. To link the new data record to a data record of another table (which must have a corresponding table field of the Links type), the relevant information must be transfered in this array: $relation = array($relationFieldID, $relationTableID, $relationDatasetID); The following variables have to be replaced with appropriate values: $relationFieldID: ID of the Links type table field, of the table that contains the data record that should be linked to the newly created data record. $relationTableID: ID of the table that contains the data record that should be linked to the newly created data record. $relationDatasetID: ID of the data record that should be linked to the newly created data record. $copy The previously used data record ID of the appropriate table: The values of the data record with the specified ID are copied to the new data record. All other values (E.g. data record ID not used or “ABC”): The new data record is created with default values. $version False, 0, zero: A new record is created as version ‘1’. All other values: The new data record is created as a new version of the data record referenced in $copy, assuming the ‘Versioned’ function for this table is enabled and the currently logged on user has the appropriate rights to create a new version. The function call is without effect if the referenced data record is already versioned, if it does not exist, or if the value transferred is not a valid data record ID in $copy. $forceNewID Valid, still unused data record ID in the corresponding table: A new data record is created with this ID. Valid, already used data record ID in the corresponding table: Function call is without effect. Any other value (such as zero, number less 1, text): A new data record is created with an ID assigned byLIMBAS. Return Value 0, false: With the parameters transferred, no new record could be created. Number other than 0: ID of the newly created data record. Exception: If for $forceNewID a data record ID is transferred, that already existed, it is returned and no new data record is created by LIMBAS. Example This example creates a new data record in the ‘Contacts’ table. The new data record is linked to a data record of the ‘Customer’ table. In addition, ‘Last name‘ and ‘First name‘ are changed for the newly created contact. $relation = array(FIELD_ID_KONTAKTE, TABLE_ID_KUNDEN, ID_KUNDEN); if($newid = new_data(TABLE_ID_KONTAKTE, $relation)){ $update[TABLE_ID_KONTAKTE.",1,$newid"] = $name; $update[TABLE_ID_KONTAKTE.",2,$newid"] = $vorname; update_data($update); }