Home > other >  Consult, yii2 query data is empty, but the generated SQL statement to execute it is data
Consult, yii2 query data is empty, but the generated SQL statement to execute it is data

Time:12-15

if (! Empty ($this - & gt; Lat) & amp; & ! Empty ($this - & gt; LNG) & amp; & ! Empty ($this - & gt; Near_distance))
{
CircleDistance: : getInstance ($query, $this - & gt; LNG, $this - & gt; Lat, $this - & gt; Near_distance);
}
Elseif (! Empty ($this - & gt; Lat) | |! Empty ($this - & gt; LNG))
{
$query - & gt; [' lat andFilterWhere (=& gt; empty ($this - & gt; lat)? Null: (double) $this - & gt; lat, 'LNG=& gt; empty ($this - & gt; LNG)? Null: (double) $this - & gt; LNG]);
}

Through the background debug debugging is execute statement is:
SELECT * FROM ` s_hotel ` WHERE (` lat `=26.411867) AND (` LNG `=108.831512) ORDER BY ` hotel_id ` LIMIT 20;

But returns an empty data, directly to the execution of the statement on the MySQL command line data,
The same debug after I add a parameter query is:
SELECT * FROM ` s_hotel ` WHERE (((` lat ` & gt;=26.411417348937) AND (` lat ` & lt;=26.412316651063) AND (` LNG ` & gt;=108.83100994417) AND (` LNG ` & lt;=108.83201405583) ORDER BY ` hotel_id ` LIMIT 20;

Then return the result data, also will be executed this statement to the command line also has data,
Consult, the problem may appear in where?

CodePudding user response:

Two environment on=& gt;=is different processing,
SELECT * FROM s_hotel WHERE (lat like "26.411867") AND (LNG like "108.831512") ORDER BY hotel_id LIMIT 20

CodePudding user response:

Feel this level is not too yes
SELECT * FROM s_hotel WHERE
(
(
(lat & gt;=26.411417348937)
AND
(lat & lt;=26.412316651063)
)
AND
(LNG & gt;=108.83100994417)
)
AND
(LNG & lt;=108.83201405583)
The ORDER BY hotel_id
LIMIT of 20

CodePudding user response:

The building Lord solve no