@@ -104,7 +104,7 @@ public function findLastBikeRentByUser(int $bikeNumber, int $userId): ?array
104104 WHERE bikeNum = :bikeNumber
105105 AND userId = :userId
106106 AND action = :rentAction
107- ORDER BY time DESC
107+ ORDER BY time DESC, id DESC
108108 LIMIT 1 " ,
109109 [
110110 'bikeNumber ' => $ bikeNumber ,
@@ -149,7 +149,7 @@ public function findConfirmationRequest(string $checkCode, int $userId): ?array
149149 WHERE action = :phoneConfirmRequestAction
150150 AND parameter = :checkCode
151151 AND userId = :userId
152- ORDER BY time DESC
152+ ORDER BY time DESC, id DESC
153153 LIMIT 1 " ,
154154 [
155155 'checkCode ' => $ checkCode ,
@@ -263,7 +263,7 @@ public function findLastReturnStand(int $bikeNum): ?array
263263 LEFT JOIN history ON stands.standId = parameter
264264 WHERE bikeNum = :bikeNum
265265 AND action IN (:returnAction, :forceReturnAction)
266- ORDER BY time DESC
266+ ORDER BY time DESC, history.id DESC
267267 LIMIT 1 " ,
268268 [
269269 'bikeNum ' => $ bikeNum ,
@@ -291,7 +291,7 @@ public function findLastRentCode(int $bikeNum): ?string
291291 FROM history
292292 WHERE bikeNum = :bikeNum
293293 AND action IN (:rentAction, :forceRentAction)
294- ORDER BY time DESC
294+ ORDER BY time DESC, id DESC
295295 LIMIT 1 " ,
296296 [
297297 'bikeNum ' => $ bikeNum ,
@@ -352,17 +352,17 @@ public function findUserTripHistory(int $userId, int $limit = 10): array
352352 (SELECT r.time FROM history r
353353 WHERE r.userId = h.userId AND r.bikeNum = h.bikeNum
354354 AND r.action IN (:returnAction, :forceReturnAction) AND r.time >= h.time
355- ORDER BY r.time ASC LIMIT 1) AS returnTime,
355+ ORDER BY r.time ASC, r.id ASC LIMIT 1) AS returnTime,
356356 (SELECT s.standName FROM history r
357357 LEFT JOIN stands s ON s.standId = r.parameter
358358 WHERE r.userId = h.userId AND r.bikeNum = h.bikeNum
359359 AND r.action IN (:returnAction2, :forceReturnAction2) AND r.time >= h.time
360- ORDER BY r.time ASC LIMIT 1) AS standName,
360+ ORDER BY r.time ASC, r.id ASC LIMIT 1) AS standName,
361361 (SELECT s2.standName FROM history r2
362362 LEFT JOIN stands s2 ON s2.standId = r2.parameter
363363 WHERE r2.bikeNum = h.bikeNum
364364 AND r2.action IN (:returnAction3, :forceReturnAction3) AND r2.time < h.time
365- ORDER BY r2.time DESC LIMIT 1) AS fromStandName
365+ ORDER BY r2.time DESC, r2.id DESC LIMIT 1) AS fromStandName
366366 FROM history h
367367 WHERE h.userId = :userId AND h.action IN (:rentAction, :forceRentAction)
368368 ORDER BY h.time DESC, h.id DESC
0 commit comments