From aadeac9f866a6968720207f005e8c646ca46465b Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Wed, 15 May 2013 18:11:06 +0200 Subject: [PATCH] properly search using getSingle, missed search field type --- public/include/classes/user.class.php | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/public/include/classes/user.class.php b/public/include/classes/user.class.php index 11f12403..f9b8e5e3 100644 --- a/public/include/classes/user.class.php +++ b/public/include/classes/user.class.php @@ -27,11 +27,11 @@ class User { } public function getUserName($id) { - return $this->getSingle($id, 'username'); + return $this->getSingle($id, 'username', 'id'); } public function getUserId($username) { - return $this->getSingle($username, 'id', 'username'); + return $this->getSingle($username, 'id', 'username', 's'); } public function checkLogin($username, $password) { @@ -55,10 +55,10 @@ class User { return $pin_hash === $row_pin; } - private function getSingle($value, $search='id', $field='id') { + private function getSingle($value, $search='id', $field='id', $type="i") { $stmt = $this->mysqli->prepare("SELECT $search FROM $this->table WHERE $field = ? LIMIT 1"); if ($this->checkStmt($stmt)) { - $stmt->bind_param('i', $value); + $stmt->bind_param($type, $value); $stmt->execute(); $stmt->bind_result($retval); $stmt->fetch(); @@ -69,7 +69,7 @@ class User { } public function getCoinAddress($userID) { - return $this->getSingle($userID, 'coin_address'); + return $this->getSingle($userID, 'coin_address', 'id', 's'); } private function updateSingle($userID, $field, $table) {