This answer告诉您如何从会话查询中获取最后一行:
<!-- Code Embed v2.3.2 -->
<?php
$con = mysqli_connect("localhost", "root", "", "demo_db");
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql="SELECT * FROM demo_table LIMIT 10";
$result = mysqli_query($con,$sql);
$data = [];
while($row = $result->fetch_array(MYSQLI_ASSOC)) {
$data[] = $row;
}
mysqli_free_result($result);
mysqli_close($con);
?>
我需要一个在前的-您如何获得倒数第二个?
答案 0 :(得分:2)
obj = session.query(ObjectRes).order_by(ObjectRes.id.desc()).offset(1).first()