You are here

function patterns_get_pattern in Patterns 7.2

Same name and namespace in other branches
  1. 5 patterns.module \patterns_get_pattern()
  2. 6.2 patterns.module \patterns_get_pattern()
  3. 6 patterns.module \patterns_get_pattern()
  4. 7 includes/ \patterns_get_pattern()

Loads the pattern from the DB and return a stdClass obj, containing the pattern code as array (unserialized).


mixed $id Numeric id or alphanumeric name of the pattern.:

Return value

stdClass $pattern The Pattern obj containing the unsereliazed pattern.

14 calls to patterns_get_pattern()
drush_patterns_info in ./
patterns list command callback.
drush_patterns_run in ./
Imports, enables, and runs the specified pattern file
PatternsExportTestCase::testExportTaxonomy in tests/exporting/exporting.test
patterns_db_get_id_from_name in includes/
Looks up a numerical id into the database for a valid patterns name. Returns false, if no valid pattern name was found.
patterns_db_get_name_from_id in includes/
Looks up a pattern name into the database and returns the numerical id associated with it. Returns false, if no valid pattern name was passed.

... See full list


includes/, line 246
Retrieve, save, and remove patterns from the database.


function patterns_get_pattern($id) {
  if (empty($id)) {
    return FALSE;
  $pattern = FALSE;
  $query = db_select('patterns', 'p')
  if (is_numeric($id)) {
    $query = $query
      ->condition('', $id);
  elseif (is_string($id)) {
    $query = $query
      ->condition('', $id);
  $pattern = $query
  if (!$pattern) {
    return FALSE;

  // Pattern data is stored in serialized form in the DB.
  $pattern[0]->pattern = unserialize($pattern[0]->pattern);
  return $pattern[0];