Why is the PDO cursor invalid?
$aa = $db->prepare('select * from user',array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL));$aa ->execute();$aa->fetch();$aa->fetch();$a=$aa->fetch(PDO::FETCH_NUM, PDO::FETCH_ORI_NEXT);print_r($a);
Enabled cursor has been set in prepare;
The result is the third line instead of the last line;
The second parameter of all fetch tests is invalid;
Ask what the reason is. Isn't this a rollback? does the table need to be INNODB?
It is hard to understand the way it is written in the manual;
Asking for help... thinks;
Reply to discussion (solution)
Of course it is the record of the third line. take a closer look at the examples in the manual and the descriptions of functions.
FETCH_ORI_NEXT
Fetch the next row in the result set. Valid only for scrollable cursors.
Remove the result set of a row
FETCH_ORI_PRIOR
Fetch the previous row in the result set. Valid only for scrollable cursors.
Returns the result set of the first row.
FETCH_ORI_FIRST (integer)
Fetch the first row in the result set. Valid only for scrollable cursors.
Obtain the first row of the result set.
FETCH_ORI_LAST
Fetch the last row in the result set. Valid only for scrollable cursors.
Returns the result set of the last row.
FETCH_ORI_ABS
Fetch the requested row by row number from the result set. Valid only for scrollable cursors.
Obtain the number of requested rows from the result set
FETCH_ORI_REL
Fetch the requested row by relative position from the current position of the cursor in the result set. Valid only for scrollable cursors.
Obtains the relative position of the requested row from the result.