Skip to content

Stdlib: PDOStatement::fetchColumn()/fetchObject()/rowCount() missing — Fatal undefined method (ext/pdo/pdo_stmt.c) #19838

Description

@PurHur

Category

stdlib · php-src-strict · PDO statement API

Problem

PDO + PDOStatement::fetch() / fetchAll() / bindValue() / execute() work on the VM sqlite path, but core statement methods from php-src are missing (method_exists false → Fatal on call). Zend ext/pdo exposes the full statement surface.

Observed on VM (2026-07-17) after PDO('sqlite::memory:') + query():

Method VM
fetch / fetchAll / bindValue / execute present
fetchColumn / fetchObject / bindColumn missing
rowCount / columnCount / getColumnMeta missing
nextRowset / closeCursor / bindParam missing
errorCode / errorInfo / setFetchMode missing
getAttribute / setAttribute / debugDumpParams missing

Minimal user-facing gap: fetchColumn() is widely used and should return the next row’s column value like Zend.

php-src reference

PHP implementation target

  • ext/pdo/ (or existing PDO builtin module) — implement PDOStatement methods in PHP + JIT lowering; thin ABI only if unavoidable
  • Prefer shipping fetchColumn + rowCount + closeCursor first; others can follow in child issues if needed
  • No new C logic in runtime/ beyond existing PDO trampolines

Repro

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
cat > /tmp/pdo_fetch_column.php <<'"'"'PHP'"'"'
<?php
$pdo = new PDO("sqlite::memory:");
$pdo->exec("CREATE TABLE t(id INTEGER); INSERT INTO t VALUES (7);");
$st = $pdo->query("SELECT id FROM t");
echo "has_fetchColumn=", method_exists($st, "fetchColumn") ? "yes" : "no", "\n";
if (method_exists($st, "fetchColumn")) {
  echo "col=", $st->fetchColumn(0), "\n";
} else {
  try { $st->fetchColumn(0); } catch (Throwable $e) { echo get_class($e), ": ", $e->getMessage(), "\n"; }
}
PHP
php bin/vm.php /tmp/pdo_fetch_column.php
'

Done when

  • PDOStatement::fetchColumn($column = 0) matches Zend (returns scalar / false when exhausted)
  • At least rowCount() and closeCursor() present and php-src-strict for sqlite
  • Compliance .phpt under test/compliance/cases/pdo/
  • php-src-strict; no php-compiler-strict shortcut

Related

#3367 (closed PDO subset epic) · #19821 (SQLite3 API) · #10533 pillar 4

Activity

  1. added
    bugSomething isn't working
    enhancementNew feature or request
    phase-4:stdlibPhase 4 – stdlib for web apps
    area:vmVirtual machine
    implementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claim
    on Jul 17, 2026
  2. PurHur commented on Jul 17, 2026

    @PurHur
    OwnerAuthor

    claim: PHP Compiler STD Lib Advanced — batch (issues #19838, #19821)

    Sequential PRs: PDOStatement fetchColumn/rowCount/closeCursor → SQLite3 query/prepare + Result/Stmt.

  3. PurHur commented on Jul 17, 2026

    @PurHur
    OwnerAuthor

    merged: #19850

    Verification (Docker script/docker-exec.sh):

    • php bin/vm.php test/repro/pdo_statement_fetch_column.php → fetchColumn/rowCount/closeCursor/fetchObject green
    • vendor/bin/phpunit --filter pdo_statement_fetch_column → OK (2 tests)
  4. PurHur commented on Jul 17, 2026

    @PurHur
    OwnerAuthor

    PR: #19850 (merged). Follow-ups filed for remaining PDOStatement methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:vmVirtual machinebugSomething isn't workingenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web appsstdlib

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions