function patterns_get_pattern in Patterns 7
Same name and namespace in other branches
- 5 patterns.module \patterns_get_pattern()
- 6.2 patterns.module \patterns_get_pattern()
- 6 patterns.module \patterns_get_pattern()
- 7.2 includes/db.inc \patterns_get_pattern()
Loads the pattern from the DB and return a stdClass obj, containing the pattern code as array (unserialized).
Parameters
mixed $id Numeric id or alphanumeric name of the pattern.:
Return value
stdClass $pattern The Pattern obj containing the unsereliazed pattern.
15 calls to patterns_get_pattern()
- drush_patterns_info in ./
patterns.drush.inc - patterns list command callback.
- drush_patterns_run in ./
patterns.drush.inc - Imports, enables, and runs the specified pattern file
- PatternsExportTestCase::testExportTaxonomy in tests/
exporting/ exporting.test - patterns_db_get_id_from_name in includes/
db.inc - 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/
db.inc - 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.
File
- includes/
db.inc, line 232 - Retrieve, save, and remove patterns from the database.
Code
function patterns_get_pattern($id) {
if (empty($id)) {
return FALSE;
}
$pattern = FALSE;
$query = db_select('patterns', 'p')
->fields('p');
if (is_numeric($id)) {
$query = $query
->condition('p.pid', $id);
}
elseif (is_string($id)) {
$query = $query
->condition('p.name', $id);
}
$pattern = $query
->execute()
->FetchAll();
if (!$pattern) {
return FALSE;
}
// Pattern data is stored in serialized form in the DB.
$pattern[0]->pattern = unserialize($pattern[0]->pattern);
return $pattern[0];
}