title: Unable to get result of COUNT query (PHP MySQL MVC) - ("Array to string conversion")
body: <p>I ask the user to input a song title, and then run a query to find out how many times it has been performed. The data table lists Songs performed on various Dates. I am using the MVC approach using Prepared Statements.</p>
  <p>The problem: I can't figure out how to output the results. The best I can I get is &quot;Warning: Array to string conversion&quot; with an echoed result of &quot;Array&quot;</p>
  <p>The primary SQL Code in &quot;Song.class.php&quot;:</p>
  <pre><code>    protected function getSongPerfsCountTotal($Song) {
        $sql = &quot;SELECT Song, COUNT(DATEREF) as SongCount
                FROM sets
                WHERE Song = ?
                GROUP BY Song&quot;;
        $stmt = $this-&gt;connect()-&gt;prepare($sql);
        $stmt-&gt;execute([$Song]);
  
        $result = $stmt-&gt;fetchALL(PDO::FETCH_ASSOC);
        return $result;
  
  </code></pre>
  <p>The &quot;View&quot; code:</p>
  <pre><code>class SongPerfsView extends Song {
  
   public function displaySongPerfsCountTotal($Song) {
    $result = $this-&gt;getSongPerfsCountTotal($Song);
  
        echo &quot;Performance count: &quot; . ['SongCount'] . &quot;&lt;p&gt;&quot;;
  
          }
  
  </code></pre>
  <p>For clarity, the data files looks something like this:</p>
  <pre><code>
  DATEREF     SONG
  1965-01-01  I Want To Hold Your Hand
  1965-01-02  I Want To Hold Your Hand
  1965-01-02  Please Please Me
  1965-01-03  I Want To Hold Your Hand
  1965-01-04  I Want To Hold Your Hand
  1965-02-05  Please Please Me
  
  </code></pre>
  <p>Expected result after the user submits &quot;I Want To Hold Your Hand&quot; is a count of &quot;4&quot;. This is basically counting the performance dates where there is matching song on that date.</p>
  <p>Instead what I'm getting is &quot;Warning: Array to string conversion&quot; with an echoed result of &quot;Array&quot;, citing the following line as the source of the error:</p>
  <pre><code>echo &quot;Performance count: &quot; . ['SongCount'] . &quot;&lt;p&gt;&quot;;
  </code></pre>