PHP mysqli_data_seek()関数
例
結果セットの行番号15を探します。
<?php
$con=mysqli_connect("localhost","my_user","my_password","my_db");
// Check connection
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
$sql="SELECT Lastname,Age FROM Persons ORDER BY Lastname";
if ($result=mysqli_query($con,$sql))
{
// Seek to row number 15
mysqli_data_seek($result,14);
// Fetch row
$row=mysqli_fetch_row($result);
printf ("Lastname: %s Age: %s\n", $row[0], $row[1]);
// Free result set
mysqli_free_result($result);
}
mysqli_close($con);
?>
定義と使用法
mysqli_data_seek()関数は、結果ポインターを結果セット内の任意の行に調整します。
構文
mysqli_data_seek(result,offset);
パラメータ値
Parameter | Description |
---|---|
result | Required. Specifies a result set identifier returned by mysqli_query(), mysqli_store_result() or mysqli_use_result() |
offset | Required. Specifies the field offset. Must be between 0 and the total number of rows - 1 |
技術的な詳細
戻り値: | 成功するとTRUE。失敗するとFALSE |
---|---|
PHPバージョン: | 5歳以上 |
❮PHPMySQLiリファレンス