function _hosting_package_instances_load in Hosting 7.4
Same name and namespace in other branches
- 5 package/hosting_package.instance.inc \_hosting_package_instances_load()
- 6.2 package/hosting_package.instance.inc \_hosting_package_instances_load()
- 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 184 - API for mapping packages to various Hosting node types
Code
function _hosting_package_instances_load($param, $multiple = FALSE) {
$instances = array();
$query = db_select('hosting_package_instance', 'i')
->addTag('hosting_package_instances_load')
->fields('i', array(
'iid',
'version',
'version_code',
'schema_version',
'status',
'rid',
'package_id',
));
$package_alias = $query
->leftJoin('hosting_package', 'p', 'i.package_id = %alias.nid');
$query
->fields($package_alias, array(
'package_type',
'nid',
'description',
'short_name',
'old_short_name',
));
$node_package_alias = $query
->leftJoin('node', 'n', $package_alias . '.nid = %alias.nid');
$query
->fields($node_package_alias, array(
'title',
));
$node_instance_alias = $query
->leftJoin('node', 'r', 'i.rid = %alias.nid');
$query
->fields($node_instance_alias, array(
'type',
));
$platform_alias = $query
->leftJoin('hosting_platform', 'h', $node_instance_alias . '.nid = %alias.nid');
if (is_numeric($param)) {
$query
->condition('i.iid', $param);
}
elseif (is_array($param)) {
// Turn the conditions into a query.
foreach ($param as $key => $value) {
$query
->condition($key, $value);
}
}
else {
return FALSE;
}
$result = $query
->execute();
foreach ($result as $instance) {
$instance->languages = _hosting_package_instances_load_languages($instance->iid);
if (!$multiple) {
return $instance;
}
$instances[$instance->iid] = $instance;
}
return $instances;
}