PDO does not fetch any results
<p>I was using PDO queries directly in index.php file.Now I want to create separate file where I will store functions. I created one, but when I call function returns only "0". Old version works:</p>

<pre><code>$abfrage11 = "SELECT COUNT(e.event_id) as numgoals
FROM event e 
WHERE (e.match_id = '$row1-&gt;match_id' AND e.team_id = '$row1-&gt;team_a_id' AND e.eventtype IN ('soc_G','soc_PG') ) OR
      (e.match_id = '$row1-&gt;match_id' AND e.team_id = '$row1-&gt;team_b_id' AND e.eventtype = 'soc_OG' )";
$ergebnis11 = $dbh-&gt;query($abfrage11);
$row11 = $ergebnis11-&gt;fetch(PDO::FETCH_OBJ);
</code></pre>

<p>BUt in new version not:</p>

<p>separate file "storage.php":</p>

<pre><code>class StorageAccess
{
    /** @var  PDO */
    public $db;

    /**
     * @param $db
     */
    public function __construct($db)
    {
        $this-&gt;db = $db;

    }
public function getAbfrage11()
    {
        $query = "SELECT COUNT(e.event_id) as numgoals
                    FROM event e 
                    WHERE (e.match_id = :mId AND e.team_id = :tmA AND e.eventtype IN ('soc_G','soc_PG') ) OR
                          (e.match_id = :mId2 AND e.team_id = :tmB AND e.eventtype = 'soc_OG' )";
        $statement = $this-&gt;db-&gt;prepare($query);
        $statement-&gt;execute([
            ':mId' =&gt; $row1-&gt;match_id,
            ':mId2' =&gt; $row1-&gt;match_id,
            ':tmA' =&gt; $row1-&gt;team_a_id,
            ':tmB' =&gt; $row1-&gt;team_b_id,
        ]);
        return $statement-&gt;fetchObject();
    }
}
</code></pre>

<p>call in index.php: </p>

<pre><code>require_once("dblogin.php");
require_once("Storage.php");

$dbFactory = new RepositoriesFactory();
$dbh = $dbFactory-&gt;getDataBaseInstance('admgsa_gsa');
$storage_access = new StorageAccess($dbh);

$row11 = $storage_access-&gt;getAbfrage11();
echo "&lt;span class='live-monitor-8' style=\"$goalscbgcolor\"&gt;$row11-&gt;numgoals&lt;/span&gt;";
</code></pre>

<p>Tried to search for the solution, but could not find anything. Thanks for help in advance.</p>