Tuesday, February 26, 2013

MySQL FOUND_ROWS() and OpenBD

We recently switched to OpenBD on a production website and it uses MySQL FOUND_ROWS().  There a couple of things to ensure it works properly on OpenBD.


You need to add this setting to the "Connection Settings" in the datasource


useDynamicCharsetInfo=false


The queries need to be in a cftransaction block otherwise they will use a different MySQL connection.   It would look something like:



<cftransaction>
<cfquery name="foo" datasource="foo">
    SELECT SQL_CALC_FOUND_ROWS * FROM foo 
    WHERE id > 2 LIMIT 2
  </cfquery>
  <cfquery name="bar" datasource="foo">
    SELECT FOUND_ROWS() AS numRows
  </cfquery>
</cftransaction>


No comments:

Post a Comment