Zesty
Zesty

Reputation: 281

How to output column data

I've been trying to output column data for a specific user, but it always seems to not work and it doesn't give me any type of error.

What it should do is get the UserId then output that column's data, but in my situation it's actually outputting the user's ID instead of the column data.

[08:21:12[PM]][DEBUG] =>> Packet Sent: %xt%up%-1%1%1%

The last number 1 is what the method below sends back which is wrong.

method getColumnsById( $intID, $columns ) {

    my $resQuery = $self->{connection}->prepare( "SELECT $columns FROM `users` WHERE `ID` = ?" );

    $resQuery->execute( $intID );

    my $arrResult = $resQuery->fetchrow_arrayref( 0 );

    if ( $arrResult ) {
        return $arrResult;
    }
}

Example:

Username is Test, and it selects column nameglow then it should display the column data as like `0xFF000... or whatever the user has their column set to.

Upvotes: 0

Views: 85

Answers (1)

Zesty
Zesty

Reputation: 281

Nevermind I fixed it

method getColumnsById($intID, $columns) {

        my $resQuery = $self->{connection}->prepare("SELECT $columns FROM `users` WHERE `ID` = ?");
        $resQuery->execute($intID);
        my $arrResult = $resQuery->fetchrow_hashref;
        if ($arrResult) {
           return $arrResult->{$columns};

        }
}

Upvotes: -1

Related Questions