Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PDO_MySQL does not support cursors #1883

Open
1107012776 opened this issue Oct 12, 2022 · 2 comments
Open

PDO_MySQL does not support cursors #1883

1107012776 opened this issue Oct 12, 2022 · 2 comments
Labels
bug Documentation contains incorrect information Extension: pdo All PDO related doc issues

Comments

@1107012776
Copy link

Description

For example, I have a table with two fields: id and value. I inserted nearly 100k rows into this table.
I want to use the scrollable cursor. I wrote the following code:

$sql = 'SELECT id FROM cursor_ test;';
$stmt = $dbh->prepare($sql, array(PDO::ATTR_CURSOR => PDO::CURSOR_SCROLL));
$stmt ->Execute ();
$row = $stmt->fetch(PDO::FETCH_ASSOC, PDO::FETCH_ORI_ABS, 3);
var_ dump($row['id']); // 1, the expected value is 3

What did I do wrong?

PHP Version

PHP5.6.25

Operating System

window7

@1107012776 1107012776 added bug Documentation contains incorrect information Status: Needs Triage labels Oct 12, 2022
@1107012776 1107012776 changed the title PHP PDO connects to MySQL using PDO:: CURSOR_ Invalid SCROLL cursor, unable to scroll to get the desired row PHP PDO connects to MySQL using PDO:: CURSOR_ SCROLL cursor, unable to scroll to get the desired row Oct 12, 2022
@cmb69
Copy link
Contributor

cmb69 commented Oct 12, 2022

PDO_MySQL does not support scrolling cursors (actually, it doesn't support cursors at all), and to my knowledge, MySQL does not support scrolling cursors, so this will not be implemented for PDO. However, we need to document this.

PHP5.6.25

Ugh. I suggest you upgrade to PHP 8 as soon as possible.

@cmb69 cmb69 transferred this issue from php/php-src Oct 12, 2022
@cmb69 cmb69 changed the title PHP PDO connects to MySQL using PDO:: CURSOR_ SCROLL cursor, unable to scroll to get the desired row PDO_MySQL does not support cursors Oct 12, 2022
@kamil-tekiela
Copy link
Member

I thought PDO_MySQL supports forward-only cursors. Anyway, cursors in MySQL are pretty useless as it doesn't support scrollable cursors. We should probably mention this somewhere, but I don't know where. Maybe here? https://www.php.net/manual/en/ref.pdo-mysql.php

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Documentation contains incorrect information Extension: pdo All PDO related doc issues
Projects
None yet
Development

No branches or pull requests

4 participants