You are here

function form_builder_cache_save in Form Builder 6

Same name and namespace in other branches
  1. 7 includes/form_builder.cache.inc \form_builder_cache_save()

Save a form builder cache based on the form structure.

4 calls to form_builder_cache_save()
form_builder_cache_field_delete in includes/form_builder.cache.inc
Remove a single field from a form builder cache.
form_builder_cache_field_save in includes/form_builder.cache.inc
Add or update a single field in a form builder cache.
form_builder_interface in includes/form_builder.admin.inc
Main form building interface. Can be used as a menu callback.
form_builder_positions_submit in includes/form_builder.admin.inc
Submit handler for the form_builder_positions form.

File

includes/form_builder.cache.inc, line 42
form_builder.cache.inc Functions for temporary storage of form builder structures while editing.

Code

function form_builder_cache_save($form_type, $form_id, $form, $sid = NULL) {
  $sid = isset($sid) ? $sid : session_id();
  if (form_builder_cache_load($form_type, $form_id, $sid) === FALSE) {
    $result = db_query("INSERT INTO {form_builder_cache} (sid, type, form_id, updated, data) VALUES ('%s', '%s', '%s', %d, '%s')", $sid, $form_type, $form_id, time(), serialize($form));
  }
  else {
    $result = db_query("UPDATE {form_builder_cache} SET data = '%s', updated = %d WHERE type = '%s' AND form_id = '%s' AND sid = '%s'", serialize($form), time(), $form_type, $form_id, $sid);
  }

  // Ensure caches are fresh for any retrievals made this request.
  form_builder_cache_load(NULL, NULL, NULL, TRUE);
  return $result;
}