Note that there are some explanatory texts on larger screens.

plurals
  1. POZend 2.0 Select query not working but the same query in raw SQL works
    primarykey
    data
    text
    <p>Heres how I'm creating the query in Zend 2.0</p> <pre><code>$getVenues = $this-&gt;tableGateway-&gt;select(function (Select $select) { $select-&gt;where-&gt;greaterThanOrEqualTo('lat', (float) $lat_min); $select-&gt;where-&gt;greaterThanOrEqualTo('lng', (float) $lng_min); $select-&gt;where-&gt;lessThanOrEqualTo('lat', (float) $lat_max); $select-&gt;where-&gt;lessThanOrEqualTo('lng', (float) $lng_max); }); </code></pre> <p>Which is outputting the following query:</p> <pre><code>SELECT `venues`.* FROM `venues` WHERE `lat` &gt;= :where1 AND `lng` &gt;= :where2 AND `lat` &lt;= :where3 AND `lng` &lt;= :where4 </code></pre> <p>With the parameters for each <code>:where*</code> filled in it looks like this:</p> <pre><code>SELECT `venues`.* FROM `venues` WHERE `lat` &gt;= 39.730387437667 AND `lng` &gt;= -86.332592054637 AND `lat` &lt;= 40.020242510131 AND `lng` &lt;= -85.954901904578 </code></pre> <p>Executing the raw SQL query in phpMyAdmin returns the correct results, but my Zend 2.0 query is returning 0 rows. </p> <p>Here is a <code>var_dump</code> of the query result set from Zend:</p> <pre><code>object(Zend\Db\ResultSet\ResultSet)#227 (8) { ["allowedReturnTypes":protected]=&gt; array(2) { [0]=&gt; string(11) "arrayobject" [1]=&gt; string(5) "array" } ["arrayObjectPrototype":protected]=&gt; object(Application\Model\Venue)#208 (12) { ["id"]=&gt;NULL ["fsq_venue_id"]=&gt;NULL ["name"]=&gt;NULL ["address"]=&gt;NULL ["city"]=&gt;NULL ["state"]=&gt;NULL ["zip"]=&gt;NULL ["country"]=&gt;NULL ["cross_street"]=&gt;NULL ["lat"]=&gt;NULL ["lng"]=&gt;NULL ["updated_at"]=&gt;NULL } ["returnType":protected]=&gt; string(11) "arrayobject" ["buffer":protected]=&gt; NULL ["count":protected]=&gt; int(0) ["dataSource":protected]=&gt; object(Zend\Db\Adapter\Driver\Pdo\Result)#214 (8) { ["statementMode":protected]=&gt; string(7) "forward" ["resource":protected]=&gt; object(PDOStatement)#215 (1) { ["queryString"]=&gt; string(117) "SELECT `venues`.* FROM `venues` WHERE `lat` &gt;= :where1 AND `lng` &gt;= :where2 AND `lat` &lt;= :where3 AND `lng` &lt;= :where4" } ["options":protected]=&gt; NULL ["currentComplete":protected]=&gt; bool(false) ["currentData":protected]=&gt; NULL ["position":protected]=&gt; int(-1) ["generatedValue":protected]=&gt; string(1) "0" ["rowCount":protected]=&gt; int(0) } ["fieldCount":protected]=&gt; int(12) ["position":protected]=&gt; NULL } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload