I am creating a small project for school. I've been able to create a function which completes a working query(tested using SQL).
The error I'm getting is; Notice: Trying to get property 'tournamentName' of non-object in E:\programs\XAMPP\htdocs\Esports\View\Tournament.php on line 34.
but I'm getting that for all of them? not sure why.
If anyone could help, I would be grateful.
My code is below.
my DataAccess.php Function that runs the query is;
function getAllTourament()
{
    global $pdo; 
    $statement = $pdo ->prepare (' SELECT tournament.tournamentName,
    tournament.console,
    tournament.no_of_players,
    tournament.prize,
    game.gName,
    sponsors.sponsorName,
    venue.venue_name,
    venue.venue_location,
    venue.venue_date,
    venue.venue_time
FROM tournament, game, sponsors, venue
    WHERE tournament.gameID = game.gameID AND tournament.sponsorID = sponsors.sponsorID AND tournament.venueID = venue.venueID
    ORDER by tournament.tournamentName, console, no_of_players, prize , gName , sponsorName , venue_name,venue_location, venue_date, venue_time');
    $statement->execute();
     $result = $statement;
    return $result;   
}
Controller
    <?php
/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
require_once ("../Model/dataAccess.php");
require_once ("../Model/Game.php");
require_once ("../Model/Tournament.php");
require_once ("../Model/Sponsor.php");
require_once ("../Model/Venue.php");
$allTournament = getAllTourament();
//$allTournament = getAllT(); 
View Tournament.php
  <?php
require_once ("../Controller/allTournament.php");
?>
<?php
require "header.php";
?>
<main>
     <table>
                <thead>
                    <tr>
                        <th>Tournament Name</th>
                        <th>Console</th>
                        <th>No Of Players</th>
                        <th>Prize</th>
                        <th>Game Name </th>
                        <th>Sponsor Name </th>
                        <th>Venue Name </th>
                        <th>Venue Location </th>
                        <th>Venue Date </th>
                        <th>Venue time </th>
                    </tr>
                </thead>
                <tbody>
                    <tr> <?php foreach ($allTournament as $Tview): ?>
                        <td><?= $Tview-> tournamentName ?> </td> 
                        <td><?= $Tview-> console ?> </td>
                        <td><?= $Tview-> no_of_players ?> </td> 
                        <td><?= $Tview-> prize ?> </td> 
                        <td><?= $Tview-> gName ?> </td>
                        <td><?= $Tview-> sponsorName ?> </td>
                        <td><?= $Tview-> venue_name ?> </td>
                        <td><?= $Tview-> venue_location ?> </td>
                        <td><?= $Tview-> venue_date ?> </td>
                        <td><?= $Tview-> venue_time ?> </td>
                    </tr><?php endforeach ?>
                </tbody>
            </table>
</main>
<?php
require "footer.php";
?>
Model Tournament.php
class Tournament {
   // private $gameId; 
    private $tournamentName;
    private $console;
    private $no_of_players;
    private $prize;
    /* magic getter and setter */
    function __get($name) 
    {
        return $this->$name;
    }
    function __set ($name, $value)
    {
        $this->$name = $value;
    }
}
Model Game.php
class Game {
   // private $gameId; 
    private $gName;
    private $rating;
    private $genre;
    private $price;
    private $date;
    /* magic getter and setter */
    function __get($name) 
    {
        return $this->$name;
    }
    function __set ($name, $value)
    {
        $this->$name = $value;
    }  
}
Model Venue.php
class Venue {
   // private $id; 
    private $venue_name;
    private $venue_location;
    private $venue_time;
    private $venue_date;
    private $venue_seats;
    /* magic getter and setter */
    function __get($name) 
    {
        return $this->$name;
    }
    function __set ($name, $value)
    {
        $this->$name = $value;
    }
}
Model Sponsor.php
class Sponsor 
{
    private $sponsorName;
    private $sponsorWsite;       
    private $sponsorType;
    private $sponsorLength;
                function __get($name) {
        return $this->$name;
    }
    function __set($name, $value) {
        $this->$name = $value;
    }
}
 
    