sanitize option keys

This commit is contained in:
Dennis Eichhorn 2019-06-07 22:57:37 +02:00
parent 7572fc2d90
commit ab58467fc0

View File

@ -86,14 +86,19 @@ abstract class SettingsAbstract implements OptionsInterface
{ {
try { try {
if (!\is_array($columns)) { if (!\is_array($columns)) {
$columns = [$columns]; $keys = [$columns];
} else {
$keys = [];
foreach ($columns as $key) {
$keys[] = \is_string($key) ? (int) \preg_replace('/[^0-9.]/', '', $key) : $key;
}
} }
$options = []; $options = [];
$query = new Builder($this->connection); $query = new Builder($this->connection);
$sql = $query->select(...static::$columns) $sql = $query->select(...static::$columns)
->from($this->connection->prefix . static::$table) ->from($this->connection->prefix . static::$table)
->where(static::$columns[0], 'in', $columns) ->where(static::$columns[0], 'in', $keys)
->toSql(); ->toSql();
$sth = $this->connection->con->prepare($sql); $sth = $this->connection->con->prepare($sql);