I'm in the process of learning to use OOP in php, I'm having a few issues with what is probably a really simple solution that I'm just not using the right search terminology to find.
I have my class
class user {
function getUser() {
if ($_SESSION['status'] == "authorized") {
$conn = new PDO( DB_DSN, DB_USERNAME, DB_PASSWORD );
$sql = "SELECT * FROM users WHERE username = :username";
$st = $conn->prepare( $sql );
$st->bindValue( ":username", $_SESSION['usernames'], PDO::PARAM_STR );
$st->execute();
$row = $st->fetch();
$conn = null;
return $row;
}
}
}
and then in my template file i'm calling the following
$user = new user();
echo $user->getUser->icon;
hopefully the bottom line shows what i'm trying to call, basically in the sql results I'm after just calling $row['icon']; directly from the return array.
is this possible? if so could someone point out the terminology i'm missing
Thanks in advance