Skip to content

Stdlib: ext/mysqli — mysqli_connect/query/fetch (ext/mysqli parity) #3435

Description

@PurHur

Category

stdlib

Problem

The MySQL improved extension (mysqli_* procedural API + mysqli class) is absent from ext/. Web stacks, WordPress-style apps, and test harnesses expect mysqli_connect(), mysqli_query(), and result fetching. Today:

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh && php bin/vm.php -r "var_export(function_exists(\"mysqli_connect\"));"'
# bool(false)

php-src reference

Repro (failure today)

test/repro/maintainer_mysqli_connect.php:

<?php
var_export(function_exists('mysqli_connect'));
echo "\n";
var_export(class_exists('mysqli'));
echo "\n";
$mysqli = @mysqli_connect('127.0.0.1', 'root', '', 'test', 3306);
if (false === $mysqli) {
    echo 'connect_fail:', mysqli_connect_errno(), ':', mysqli_connect_error(), "\n";
    exit(0);
}
mysqli_query($mysqli, 'SELECT 1 AS n');
$r = mysqli_fetch_assoc(mysqli_query($mysqli, 'SELECT 1 AS n'));
var_export($r);
echo "\n";
mysqli_close($mysqli);
./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
php test/repro/maintainer_mysqli_connect.php      # Zend (if ext/mysqli + server)
php bin/vm.php test/repro/maintainer_mysqli_connect.php 2>&1 | head -3
'
Runtime function_exists Query result
Zend + MariaDB true array('n' => '1')
bin/vm.php false Call to undefined function mysqli_connect()

Scope (v1 subset — this repo)

Piece Path Notes
Module ext/mysqli/Module.php Register procedural + mysqli class
Connection ext/mysqli/mysqli_connect.php, mysqli_close.php Thin wrapper over libmysqlclient / mariadb FFI
Query ext/mysqli/mysqli_query.php, mysqli_fetch_assoc.php Buffered result set v1
Errors mysqli_connect_errno(), mysqli_connect_error() Match Zend strings
Resource VM TYPE_RESOURCE or dedicated link object Mirror #3367 PDO pattern
Tests test/compliance/cases/stdlib/mysqli_select1.phpt Skip when MYSQLI_TEST_DSN unset
JIT/AOT VM-only v1 Document deferral in matrix

Phase 2 (separate issues): mysqli_prepare / mysqli_stmt_*, mysqli_real_escape_string, mysqli_multi_query, mysqli_driver.

PHP-in-PHP: implement connection/query in ext/mysqli/*.php; C only for unavoidable libmysqlclient FFI.

Done when

  • function_exists('mysqli_connect') and class_exists('mysqli') true on VM
  • With MYSQLI_TEST_DSN env (documented in PHPT --SKIPIF--), repro prints array('n' => '1') or '1'
  • Bad host → mysqli_connect_errno() non-zero; message non-empty (Zend subset)
  • ./script/ci-fast.sh --filter mysqli_select1 green (skips without DSN)
  • Capability matrix row via script/capability-matrix.php

Verification

./script/docker-exec.sh -- bash -lc 'source script/php-env.sh
export MYSQLI_TEST_DSN="mysqli://root@127.0.0.1/test"
vendor/bin/phpunit --filter mysqli_select1
'

Environment

  • Compliance tests must --SKIPIF-- when no MySQL/MariaDB (do not require DB in default ci-fast).
  • Docker dev image may not ship mysqld; document optional docker-compose service in PHPT header.

Links

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