PHP PDO count and sum value from MySQL table
<p>Well, I'm pretty sure this is just a novice question, so please forgive me for that, but I feel like I'm losing my mind.</p>

<p>I have a simple MySQL rating table and I need to count rows and to sum rates values (int) with PHP PDO</p>

<pre><code>$sql = "SELECT rate FROM rating_table";
$query = $db-&gt;query($sql);            

$rate_times = count($query-&gt;fetchAll()); // it works! 
echo '&lt;p&gt;'.$rate_times.'&lt;/p&gt;';

$sum_rates = array_sum($query-&gt;fetchAll()); // it doesn't work!
echo '&lt;p&gt;'.$sum_rates.'&lt;/p&gt;';
</code></pre>

<p>Thank you in advance for any suggestion</p>