虽然文档说您必须提供 0 到 count - 1 之间的数字,但您实际上可以提供负数,它似乎被强制转换为正数(例如在 abs() 中)。
例如
<?php
$db = new mysqli('localhost', 'test', 'password', 'schema');
$db->multi_query("
SELECT * FROM
(
SELECT 1 as 'position'
UNION SELECT 2 as 'position'
UNION SELECT 3 as 'position'
UNION SELECT 4 as 'position'
UNION SELECT 5 as 'position'
) as rows");
$result = $db->store_result();
for ($i = 0; $i < $result->num_rows; $i++)
{
$offset = $i;
$result->data_seek($offset);
var_dump("Seek offset is: {$offset}", $result->fetch_object());
}
for ($i = 0; $i < $result->num_rows; $i++)
{
$offset = -$i;
$result->data_seek($offset);
var_dump("Seek offset is: {$offset}", $result->fetch_object());
}