title: return result from model to view (right MVC conception)
body: <p>I dont know a good MVC pattern, now learn... So, I want to make: obtain rows from database, if result none (0 rows) print "we have no results", otherwise print results.</p>
  
  <p>In model I have this php code</p>
  
  <pre><code>function getAutos () {
      //here connect to database
  
      $res = $this-&gt;db-&gt;query("SELECT names FROM auto");
      if ($res-&gt;num_rows == 0) {
          return "we have no results";
      }
      else {
          return $res;
      }
  
  }
  </code></pre>
  
  <p>this function  returns object or string, right? now in view I make:</p>
  
  <pre><code>&lt;!--some html code --&gt;
  &lt;?php
  $resultFromGetAutos  = /*result from function getAutos ()*/
  
  if (is_object(resultFromGetAutos)) {
       while ($row = resultFromGetAutos-&gt;fetch_assoc()) {
           echo row['names']."&lt;br&gt;";
      }
  }
  else {
      echo resultFromGetAutos;
  }
  ?&gt;
  &lt;!--some html code --&gt;
  </code></pre>
  
  <p>It works, but as I understood, many PHP code  in view, is not right MVC, that is when I check result type in view: <code>if (is_object(Resultat)) {do something} else { do other something }</code>  this is not right MVC conception? if not right, how is right way in such situations?</p>