function hosting_package_comparison

7.x-3.x hosting_package.instance.inc hosting_package_comparison($current, $target)

@todo Please document this function.

See also

http://drupal.org/node/1354

2 calls to hosting_package_comparison()
hosting_migrate_platform_batch in migrate/hosting_migrate.batch.inc
Batch comparison of site packages between platforms to determine if the site can be migrated to the target platform or not.
hosting_task_migrate_form in migrate/hosting_migrate.module
Implements hook_form().

File

package/hosting_package.instance.inc, line 332
API for mapping packages to various Hosting node types

Code

function hosting_package_comparison($current, $target) {

  $current_table = _hosting_package_temporary_table($current);
  $target_table = _hosting_package_temporary_table($target);

  $status = array();
  $result = db_query("SELECT count(c.nid) AS error
                      FROM $current_table c
                      LEFT JOIN $target_table t
                      ON c.nid=t.nid
                      WHERE (t.schema_version > 0) && (c.schema_version > t.schema_version)
                      AND c.status = :cstatus", array(
    ':cstatus' => 1,
  ));

  foreach ($result as $obj) {
    $status['error'] = $obj->error;
  }

  $result = db_query("SELECT COUNT(c.nid) AS missing
                      FROM $current_table c
                      LEFT JOIN $target_table t
                      ON c.nid=t.nid
                      WHERE t.nid IS NULL
                      AND c.status = :c_status", array(
    ':c_status' => 1,
  ));
  foreach ($result as $obj) {
    $status['missing'] = $obj->missing;
  }

  $result = db_query("SELECT COUNT(c.nid) as upgrade
                      FROM $current_table c
                      LEFT JOIN $target_table t
                      ON c.nid=t.nid
                      WHERE (c.version_code < t.version_code) OR (c.schema_version < t.schema_version)
                      AND c.status = :c_status", array(
    ':c_status' => 1,
  ));

  foreach ($result as $obj) {
    $status['upgrade'] = $obj->upgrade;
  }

  $result = db_query("SELECT count(c.nid) AS downgrade
                      FROM $current_table c
                      LEFT JOIN $target_table t
                      ON c.nid=t.nid
                      WHERE (c.version_code > t.version_code)");

  foreach ($result as $obj) {
    $status['downgrade'] = $obj->downgrade;
  }

  return $status;
}