You are here

function _hosting_package_load in Hosting 7.4

Same name and namespace in other branches
  1. 5 package/hosting_package.module \_hosting_package_load()
  2. 6.2 package/hosting_package.module \_hosting_package_load()
  3. 7.3 package/hosting_package.module \_hosting_package_load()

A generic method for finding whichever packages you are looking for.

This works similarly to node_load's implementation, but it will only look for fields related to packages.

Parameters

An associated array containing the following properties:

  • name => A string containing the friendly name of the package
  • short_name => The name of the drupal package in the system table
  • old_short_name => The name that a package used to be called, for migration purposes.
  • package_type => The type of package. (theme|module|profile|engine)

Return value

array|bool

File

package/hosting_package.module, line 204
Defines package node types

Code

function _hosting_package_load($param) {

  // Turn the conditions into a query.
  foreach ($param as $key => $value) {
    $cond[] = 'p.' . db_escape_table($key) . " = '%s'";
    $arguments[] = $value;
  }
  $cond = implode(' AND ', $cond);

  // TODO convert this statement to a DBTNG dynamic query.
  $result = db_query('SELECT n.nid FROM {node} n left join {hosting_package} p on n.nid = p.nid WHERE ' . $cond, $arguments);
  while ($nid = $result
    ->fetch()) {
    $return[$nid->nid] = node_load($nid->nid);
  }
  if (sizeof($return)) {
    return $return;
  }
  return NULL;
}