You are here

function sbp_paths_update_6000 in Search by Page 6

Same name and namespace in other branches
  1. 7 sbp_paths.install \sbp_paths_update_6000()

Adds languages, environment, and uname fields to sbpp_path table.

File

./sbp_paths.install, line 78
Install hooks for sbp_paths module

Code

function sbp_paths_update_6000() {
  $ret = array();
  db_add_field($ret, 'sbpp_path', 'languages', array(
    'description' => t('Serialized array of languages that can be used for this path'),
    'type' => 'text',
  ));
  db_add_field($ret, 'sbpp_path', 'environment', array(
    'description' => t('Environment ID'),
    'type' => 'int',
    'size' => 'big',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 0,
  ));
  db_add_index($ret, 'sbpp_path', 'envi', array(
    'environment',
  ));
  db_add_field($ret, 'sbpp_path', 'uname', array(
    'description' => t('User name used to index this path'),
    'type' => 'varchar',
    'length' => '60',
  ));

  // Set default for languages and environment
  $lang = language_default('language');
  $val = serialize(array(
    $lang => $lang,
  ));

  // Note: Cannot use update_sql here because of serialized data!
  $out = db_query("UPDATE {sbpp_path} SET languages='%s'", $val);

  // CODER-IGNORE-THIS
  if ($out) {
    $ret[] = array(
      'success' => TRUE,
      'query' => "UPDATE {sbpp_path} SET languages='%s'",
    );
  }
  else {
    $ret[] = array(
      'success' => FALSE,
      'query' => "UPDATE {sbpp_path} SET languages='%s'",
    );
  }
  $ret[] = update_sql("UPDATE {sbpp_path} SET environment=1");
  return $ret;
}