|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2015-11-04 14:50 UTC] rmoisto at gmail dot com
Description:
------------
The select_db function does not work and produces a Warning when using a class that extends mysqli.
This worked perfectly with PHP 5.6. As I have both PHP versions installed on this computer I switched between them several times to confirm this.
I'm using PHP 7 RC6 that I compiled from source.
The web server is nginx, using PHP with FPM.
Test script:
---------------
<?php
class MyMysqli extends mysqli {
public function e_select_db($db) {
return $this->select_db($db);
}
}
$mysqli = new MyMysqli('localhost', 'root', 'password');
$mysqli->e_select_db('db');
Expected result:
----------------
Database is selected.
Actual result:
--------------
Database is not selected.
Also, the following Warning is written to the error log:
PHP message: PHP Warning: mysqli::select_db(): Couldn't fetch MyMysqli in /var/www/public_html/test.php on line 4" while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET /test.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php7-fpm.sock:", host: "localhost"
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 09:00:01 2025 UTC |
Seems I was not looking at my error log quite right, there's also an issue with connecting. Simpler test script: <?php $mysqli = new mysqli('localhost', 'root', 'password'); $mysqli->select_db('db'); Full Warning: 2015/11/04 16:58:17 [error] 20107#0: *2075 FastCGI sent in stderr: "PHP message: PHP Warning: mysqli::__construct(): (HY000/2002): No such file or directory in /var/www/enternum/public_html/test.php on line 2 PHP message: PHP Warning: mysqli::select_db(): Couldn't fetch mysqli in /var/www/public_html/test.php on line 3" while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET /test.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php7-fpm.sock:", host: "localhost"