You are here

function _hosting_package_instances_load in Hosting 6.2

Same name and namespace in other branches
  1. 5 package/hosting_package.instance.inc \_hosting_package_instances_load()
  2. 7.4 package/hosting_package.instance.inc \_hosting_package_instances_load()
  3. 7.3 package/hosting_package.instance.inc \_hosting_package_instances_load()

Internal function for hosting_package_instance(s)_load.

2 calls to _hosting_package_instances_load()
hosting_package_instances_load in package/hosting_package.instance.inc
Get an array of all package instance objects that match given parameters.
hosting_package_instance_load in package/hosting_package.instance.inc
Get the first package instance object that maches given parameters.

File

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

Code

function _hosting_package_instances_load($param, $multiple = FALSE) {
  $arguments = array();
  if (is_numeric($param)) {
    $cond = 'iid = %d';
    $arguments[] = $param;
  }
  elseif (is_array($param)) {

    // Turn the conditions into a query.
    foreach ($param as $key => $value) {
      $cond[] = $key . " = '%s'";
      $arguments[] = $value;
    }
    $cond = implode(' AND ', $cond);
  }
  else {
    return FALSE;
  }
  $instances = array();
  $result = db_query("SELECT\n      n.title, r.type, p.package_type, p.nid,\n      i.iid, i.version, i.version_code, i.schema_version,\n      i.status, i.platform, p.description, p.short_name, p.old_short_name, i.rid,\n      i.package_id\n      FROM {hosting_package_instance} i\n        LEFT JOIN {hosting_package} p ON p.nid=i.package_id\n        LEFT JOIN {node} n ON p.nid=n.nid\n        LEFT JOIN {node} r ON r.nid=i.rid\n        LEFT JOIN {hosting_platform} h ON r.nid=h.nid\n      WHERE " . $cond, $arguments);
  while ($instance = db_fetch_object($result)) {
    $instance->languages = _hosting_package_instances_load_languages($instance->iid);
    if (!$multiple) {
      return $instance;
    }
    $instances[$instance->iid] = $instance;
  }
  return $instances;
}