Open Source RDBMS - Seamless, Scalable, Stable and Free

한국어 | Login |Register

Versions available for this page: CUBRID 8.2.1 |  CUBRID 8.3.0 |  CUBRID 8.3.1 |  CUBRID 8.4.0 |  CUBRID 8.4.1 | 



cubrid_move_cursor

Description

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.

Syntax

int cubrid_move_cursor (resource $req_identifier, int $offset[, int $origin])

  • req_identifier : Request identifier
  • offset : The number of positions to which the cursor is to be moved
  • origin : Origin of the cursor movement
    CUBRID_CURSOR_FIRST,
    CUBRID_CURSOR_CURRENT,
    CUBRID_CURSOR_LAST
Return Value
  • Success : CUBRID_CURSOR_SUCCESS
  • No data : CUBRID_NO_MORE_DATA
  • Failure : CUBRID_CURSOR_ERROR
Example

<?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"

}

See Also