Skip to content

Commit

Permalink
pkp#5023 Add impossible clause for no values listed
Browse files Browse the repository at this point in the history
  • Loading branch information
asmecher committed Sep 10, 2019
1 parent aa5946c commit 14e212d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion classes/statistics/PKPMetricsDAO.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,13 +146,16 @@ function &getMetrics($metricType, $columns = array(), $filters = array(), $order
if (is_scalar($values)) {
$currentClause .= "$column = ?";
$params[] = $values;
} else {
} elseif (count($values)) {
$placeholders = array_pad(array(), count($values), '?');
$placeholders = implode(', ', $placeholders);
$currentClause .= "$column IN ($placeholders)";
foreach ($values as $value) {
$params[] = $value;
}
} else {
// count($values) == 0: No matches should be returned.
$currentClause .= '1=0';
}
}

Expand Down

0 comments on commit 14e212d

Please sign in to comment.