title: Zend Framework 2 Zend\Db\Sql\Sql - prepareStatementForSqlObject vs getSqlStringForSqlObject
body: <p>In reading the Zend Framework 2 Documentation: <a href="http://framework.zend.com/manual/2.0/en/modules/zend.db.sql.html" rel="nofollow">http://framework.zend.com/manual/2.0/en/modules/zend.db.sql.html</a> two examples are given on how one might query data from the Database. For reference, they are:</p>
  
  <p>To prepare (using a Select object):</p>
  
  <pre><code>use Zend\Db\Sql\Sql;
  $sql = new Sql($adapter);
  $select = $sql-&gt;select();
  $select-&gt;from('foo');
  $select-&gt;where(array('id' =&gt; 2));
  
  $statement = $sql-&gt;prepareStatementForSqlObject($select);
  $results = $statement-&gt;execute();
  </code></pre>
  
  <p>To execute (using a Select object)  </p>
  
  <pre><code>use Zend\Db\Sql\Sql;
  $sql = new Sql($adapter);
  $select = $sql-&gt;select();
  $select-&gt;from('foo');
  $select-&gt;where(array('id' =&gt; 2));
  
  $selectString = $sql-&gt;getSqlStringForSqlObject($select);
  $results = $adapter-&gt;query($selectString, $adapter::QUERY_MODE_EXECUTE);
  </code></pre>
  
  <p>I was unable to find any further instruction in the documentation as to what advantages/disadvantages one method may have over the other in certain situations. I can see that if we needed to debug our SQL query, the getSqlStringForSqlObject would help us to do so. But beyond that, does anyone know a situation where one method may be better than the other? </p>
  
  <p>Thanks.</p>