From 3844bbe1abf00d99b258bf357078de6dfbfb48c5 Mon Sep 17 00:00:00 2001 From: Sebastian Grewe Date: Sun, 12 May 2013 16:56:11 +0200 Subject: [PATCH] cleaned up getSingle calls, added getCoinAddress method --- public/include/classes/user.class.php | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/public/include/classes/user.class.php b/public/include/classes/user.class.php index f417fc8c..0e7b3019 100644 --- a/public/include/classes/user.class.php +++ b/public/include/classes/user.class.php @@ -27,7 +27,7 @@ class User { } public function getUserName($userID) { - return $this->getSingle($userID, 'id', 'username', $this->table); + return $this->getSingle($userID, 'username'); } public function checkLogin($username, $password) { @@ -51,22 +51,23 @@ class User { return $pin_hash === $row_pin; } - private function getSingle($userID, $search='id', $field='id', $table='') { - if ( empty($table) ) { - $table = $this->table; - } - // Hack for inconsistent field names - $stmt = $this->mysqli->prepare("SELECT $field FROM $table WHERE $search=? LIMIT 1"); + private function getSingle($userID, $search='id') { + $stmt = $this->mysqli->prepare("SELECT $search FROM $this->table WHERE id = ? LIMIT 1"); if ($this->checkStmt($stmt)) { $stmt->bind_param('i', $userID); $stmt->execute(); - $stmt->bind_result($value); + $stmt->bind_result($retval); $stmt->fetch(); $stmt->close(); - return $value; + return $retval; } return false; } + + public function getCoinAddress($userID) { + return $this->getSingle($userID, 'coin_address'); + } + private function updateSingle($userID, $field, $table) { $stmt = $this->mysqli->prepare("UPDATE $table SET " . $field['name'] . " = ? WHERE userId = ? LIMIT 1"); if ($this->checkStmt($stmt)) {