public function update($username, array $data) {
        $cond = array();
        unset($data[$this->params['id']]);
		unset($data[$this->params['password']]);

        if($this->params['token']) {
            unset($data[$this->params['token']]);
        }

        if($this->params['created']) {
            unset($data[$this->params['created']]);
        }

        if($this->params['last_login']) {
            unset($data[$this->params['last_login']]);
        }


        foreach($data as $k => $v) {
            $cond[] = sprintf("`%s` = %s", str_replace(array('\\',"\0" ,'`'), '', $k), $this->pdo->quote($v));
        }


        if(is_numeric($username)) {
            $key = 'id';
        }
        else {
            $key = 'username';
        }

        $query = sprintf(self::UPDATE_QUERY,
            $this->params['table'],
            implode(', ', $cond),
            $this->params[$key],
            $this->pdo->quote($username));

        $stmt = $this->pdo->query($query);

        if($stmt === FALSE) {
            throw new UserException(json_encode($this->pdo->errorInfo()));
        }

    }