static function configUpdate($input, $force = FALSE)
{
$dbo = Pommo::$_dbo;
if (!is_array($input)) {
Pommo::kill('Bad input passed to updateConfig', TRUE);
}
// if this is password, skip if empty
if (isset($input['admin_password']) && empty($input['admin_password'])) {
unset($input['admin_password']);
}
// get eligible config rows/options to change
$force = $force ? null : 'on';
$query = "\n SELECT config_name\n FROM " . $dbo->table['config'] . "\n WHERE config_name IN(%q)\n [AND user_change='%S']";
$query = $dbo->prepare($query, array(array_keys($input), $force));
// update rows/options
$when = '';
// multi-row update in a single query syntax
while ($row = $dbo->getRows($query)) {
$when .= $dbo->prepare("WHEN '%s' THEN '%s'", array($row['config_name'], $input[$row['config_name']])) . ' ';
// limits multi-row update query to specific rows
// (vs updating entire table)
$where[] = $row['config_name'];
}
$query = "\n UPDATE " . $dbo->table['config'] . "\n SET config_value =\n CASE config_name " . $when . " ELSE config_value END\n [WHERE config_name IN(%Q)]";
$query = $dbo->prepare($query, array($where));
if (!$dbo->query($query)) {
Pommo::kill('Error updating config');
}
return true;
}