1
0
mirror of https://github.com/delight-im/PHP-Auth.git synced 2025-08-05 07:37:25 +02:00

Add private method 'deleteUsersByColumnValue' to 'Administration'

This commit is contained in:
Marco
2017-02-25 17:14:24 +01:00
parent f06af42f87
commit 63144d4dc0

View File

@@ -9,6 +9,7 @@
namespace Delight\Auth; namespace Delight\Auth;
use Delight\Db\PdoDatabase; use Delight\Db\PdoDatabase;
use Delight\Db\Throwable\Error;
require_once __DIR__ . '/Exceptions.php'; require_once __DIR__ . '/Exceptions.php';
@@ -57,4 +58,28 @@ final class Administration extends UserManager {
protected function throttle($actionType, $customSelector = null) {} protected function throttle($actionType, $customSelector = null) {}
/**
* Deletes all existing users where the column with the specified name has the given value
*
* You must never pass untrusted input to the parameter that takes the column name
*
* @param string $columnName the name of the column to filter by
* @param mixed $columnValue the value to look for in the selected column
* @return int the number of deleted users
* @throws AuthError if an internal problem occurred (do *not* catch)
*/
private function deleteUsersByColumnValue($columnName, $columnValue) {
try {
return $this->db->delete(
'users',
[
$columnName => $columnValue
]
);
}
catch (Error $e) {
throw new DatabaseError();
}
}
} }