You are here

function webform_component_insert in Webform 5.2

Same name and namespace in other branches
  1. 6.3 includes/webform.components.inc \webform_component_insert()
  2. 6.2 webform_components.inc \webform_component_insert()
  3. 7.4 includes/webform.components.inc \webform_component_insert()
  4. 7.3 includes/webform.components.inc \webform_component_insert()

Insert a new component into the database.

Parameters

$component: A full component containing fields from the component form.

3 calls to webform_component_insert()
webform_component_clone in ./webform_components.inc
Recursively insert components into the database.
webform_component_edit_form_submit in ./webform_components.inc
webform_insert in ./webform.module
Implementation of hook_insert().

File

./webform_components.inc, line 508
Webform module components handling.

Code

function webform_component_insert($component) {
  db_lock_table('webform_component');
  $component['cid'] = isset($component['cid']) ? $component['cid'] : db_result(db_query('SELECT MAX(cid) FROM {webform_component} WHERE nid = %d', $component['nid'])) + 1;
  $component['value'] = isset($component['value']) ? $component['value'] : NULL;
  $component['mandatory'] = isset($component['mandatory']) ? $component['mandatory'] : 0;
  db_query("INSERT INTO {webform_component} (nid, cid, pid, form_key, name, type, value, extra, mandatory, weight, email) VALUES (%d, %d, %d, '%s', '%s', '%s', '%s', '%s', %d, %d, %d)", $component['nid'], $component['cid'], $component['pid'], $component['form_key'], $component['name'], $component['type'], $component['value'], serialize($component['extra']), $component['mandatory'], $component['weight'], $component['email']);
  db_unlock_tables('webform_component');
  return $component['cid'];
}