You are here

function patterns_db_get_patterns in Patterns 7

Same name and namespace in other branches
  1. 7.2 includes/db.inc \patterns_db_get_patterns()

Returns the array of patterns objects that are currently in the database.

No further check against the file system is performed. It just returns what is in the database.

It is possible to specify which fields to return with a parameter, that can be either a string or an array.

The pattern code within each each object is still to be unserialized.

Parameters

mixed $fields Specifies which fields to return.:

Return value

array An array of all available patterns objects.

See also

patterns_io_get_patterns()

6 calls to patterns_db_get_patterns()
PatternsExportTestCase::testExportTaxonomy in tests/exporting/exporting.test
patterns_db_get_patterns_array in includes/db.inc
Returns the array of patterns loaded from the database.
patterns_examples_disable in patterns_examples/patterns_examples.install
Implements hook_uninstall().
patterns_lab in includes/forms/lab.inc
@file Functions related to exporting patterns.
patterns_lab_submit in includes/forms/lab.inc
Exports selected patterns either in a file or as a zip-archive

... See full list

File

includes/db.inc, line 296
Retrieve, save, and remove patterns from the database.

Code

function patterns_db_get_patterns($fields = array()) {
  if (!empty($fields)) {
    if (!is_array($fields)) {
      $fields = array(
        $fields,
      );
    }
  }
  $query = db_select('patterns', 'p');
  $result = $query
    ->fields('p', $fields)
    ->execute()
    ->fetchAll();
  return $result;
}