Skip to content

Stdlib: ext/pdo — PDO connect/query/fetch subset (ext/pdo parity) #3367

Description

@PurHur

Category

stdlib

Problem

Database access via PDO, PDOStatement, and driver DSNs (pdo_mysql, pdo_sqlite, …) is absent. Framework bootstrap code and many examples assume new PDO($dsn, $user, $pass) with prepared statements.

php-src reference

  • ext/pdo/pdo.c — php_pdo_register_driver, connection lifecycle
  • ext/pdo/pdo_dbh.c — PDO methods (query, prepare, exec, …)
  • ext/pdo/pdo_stmt.c — PDOStatement::fetch, fetchAll, bindValue
  • ext/pdo_mysql/, ext/pdo_sqlite/ — drivers (phase 1: sqlite in-memory OK)

Repro (today)

<?php
$pdo = new PDO('sqlite::memory:');
$pdo->exec('CREATE TABLE t (id INTEGER PRIMARY KEY, v TEXT)');
$st = $pdo->prepare('INSERT INTO t (v) VALUES (?)');
$st->execute(['hello']);
foreach ($pdo->query('SELECT v FROM t') as $row) {
    echo $row['v'], "\n";
}
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php repro.php'
/usr/bin/php repro.php   # Zend: hello

This compiler: compile/runtime error — PDO class / extension missing.

Scope (this repo)

Module Path
Extension ext/pdo/ (new), optional ext/pdo_sqlite/
OOP classes PDO, PDOStatement, PDOException in lib/VM/BuiltinClasses.php or ext
VM Prepared statements + bound parameters (subset)
Tests test/compliance/cases/stdlib/pdo_sqlite_memory.phpt

Done when

  • Repro runs on VM with sqlite::memory: and prints hello
  • PDO::ATTR_ERRMODE + exceptions on error (Zend default subset)
  • Capability matrix lists PDO; mysql driver optional follow-up issue

Related

Activity

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 machineenhancementNew feature or requestimplementation-readySpec complete: repro, php-src ref, done-when — safe for workers to claimphase-4:stdlibPhase 4 – stdlib for web apps

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions