function _patterns_db_convert_results_set in Patterns 7.2
Same name and namespace in other branches
- 7 includes/db.inc \_patterns_db_convert_results_set()
Converts all the patterns objects in a results set from a database query on the patterns table into an arrays and unserialize the pattern code, if found.
Parameters
array $set the result set:
boolean $merge if TRUE, merges all the values of: the results set into one big array. Keys are lost.
Return value
array the converted results set
2 calls to _patterns_db_convert_results_set()
- patterns_db_get_enabled_patterns_array in includes/
db.inc - Returns the array of patterns array that are currently enabled.
- patterns_db_get_patterns_array in includes/
db.inc - Returns the array of patterns loaded from the database.
File
- includes/
db.inc, line 19 - Retrieve, save, and remove patterns from the database.
Code
function _patterns_db_convert_results_set($set, $merge = FALSE) {
$out = array();
if (empty($set)) {
return $out;
}
foreach ($set as $p) {
$pa = get_object_vars($p);
if (isset($pa['pattern'])) {
$pa = unserialize($pa['pattern']);
}
if ($merge) {
$out = array_merge($out, array_values($pa));
}
else {
$out[] = $pa;
}
}
return $out;
}