PDO 的遊標為何無效?
本帖最後由 baidu_26094577 於 2015-02-27 14:53:25 編輯
$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);
prepare中已經設定了開啟遊標;
結果是第三行,而不是最後一行;
測試了所有的fetch第二個參數,均無效;
求問這是什麼原因,這個又不是復原,需要表是INNODB嗎?
按照手冊上的寫法,也不好用,很是費解;
求助中....thinks;
------解決思路----------------------
當然是第三行記錄啦,你仔細看看手冊上的例子以及函數的說明
------解決思路----------------------
FETCH_ORI_NEXT
Fetch the next row in the result set. Valid only for scrollable cursors.
取下一行的結果集
FETCH_ORI_PRIOR
Fetch the previous row in the result set. Valid only for scrollable cursors.
取前一行的結果集
FETCH_ORI_FIRST (integer)
Fetch the first row in the result set. Valid only for scrollable cursors.
取結果集中的第一行
FETCH_ORI_LAST
Fetch the last row in the result set. Valid only for scrollable cursors.
取最後一行的結果集
FETCH_ORI_ABS
Fetch the requested row by row number from the result set. Valid only for scrollable cursors.
擷取所請求的行數從結果集
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.
擷取所請求的行從結果中游標當前位置的相對位置的設定