You are here

function xmlsitemap_link_update_multiple in XML sitemap 6.2

Same name and namespace in other branches
  1. 7.2 xmlsitemap.module \xmlsitemap_link_update_multiple()

Perform a mass update of sitemap data.

If visible links are updated, this will automatically set the regenerate needed flag to TRUE.

Parameters

$updates: An array of values to update fields to, keyed by field name.

$conditions: An array of values to match keyed by field.

Return value

The number of links that were updated.

Related topics

3 calls to xmlsitemap_link_update_multiple()
XMLSitemapUnitTest::testUpdateLinks in ./xmlsitemap.test
Tests for xmlsitemap_link_update_multiple().
xmlsitemap_link_bundle_rename in ./xmlsitemap.module
xmlsitemap_link_bundle_settings_save in ./xmlsitemap.module

File

./xmlsitemap.module, line 626
Main file for the xmlsitemap module.

Code

function xmlsitemap_link_update_multiple($updates = array(), $conditions = array(), $check_flag = TRUE) {

  // If we are going to modify a visible sitemap link, we will need to set
  // the regenerate needed flag.
  if ($check_flag && !variable_get('xmlsitemap_regenerate_needed', FALSE)) {
    _xmlsitemap_check_changed_links($conditions, $updates, TRUE);
  }

  // Process updates.
  $args = array();
  module_load_include('inc', 'xmlsitemap');
  $args = _xmlsitemap_build_conditions($updates, $args, array(
    'operator' => '=',
    'update' => TRUE,
  ));
  $args = _xmlsitemap_build_conditions($conditions, $args);
  $sql = "UPDATE {xmlsitemap} SET " . implode(', ', $updates) . " WHERE " . implode(' AND ', $conditions);
  db_query($sql, $args);
  return db_affected_rows();
}