The cubrid_move_cursor function moves the current cursor position of req_identifier to the distance configured by the offset argument in the direction in the origin argument. For origin, the first position in the result (CUBRID_CURSOR_FIRST), the current position in the result (CUBRID_CURSOR_CURRENT) and the last position in the result (CUBRID_CURSOR_LAST) can be used. If origin is not specified, CUBRID_CURSOR_CURRENT is used by default.
If the amount of cursor movement exceeds the range of the result, the cursor moves to a position next to the end of the result range. For example, if the cursor moves to the position 20 when the size of the result is 10, it moves to the 11th position and returns CUBRID_NO_MORE_DATA.
int cubrid_move_cursor (resource $req_identifier, int $offset[, int $origin])
<?php
$conn = cubrid_connect("127.0.0.1", 33000, "demodb");
$req = cubrid_execute($conn, "SELECT * FROM code");
cubrid_move_cursor($req, 1, CUBRID_CURSOR_LAST);
$result = cubrid_fetch_row($req);
var_dump($result);
cubrid_move_cursor($req, 1, CUBRID_CURSOR_FIRST);
$result = cubrid_fetch_row($req);
var_dump($result);
cubrid_move_cursor($req, 1, CUBRID_CURSOR_CURRENT);
$result = cubrid_fetch_row($req);
var_dump($result);
cubrid_close_request($req);
cubrid_disconnect($conn);
?>
The above example will output:
array(2) {
[0]=>
string(1) "G"
[1]=>
string(4) "Gold"
}
array(2) {
[0]=>
string(1) "X"
[1]=>
string(5) "Mixed"
}
array(2) {
[0]=>
string(1) "M"
[1]=>
string(3) "Man"
}