Doc #69884 [Csd->ReO]: mysqli->connect_error seems to be shared across objects

From: Date: Wed, 09 Jun 2021 16:31:43 +0000
Subject: Doc #69884 [Csd->ReO]: mysqli->connect_error seems to be shared across objects
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-18841@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=69884&edit=1 ID: 69884 Updated by: cmb@php.net Reported by: phpbugs at olemartin dot org Summary: mysqli->connect_error seems to be shared across objects -Status: Closed +Status: Re-Opened Type: Documentation Problem Package: MySQLi related Operating System: Ubuntu PHP Version: 5.5.26 -Assigned To: cmb +Assigned To: Block user comment: N Private report: N New Comment: My fix was nonsense, so I reverted. Previous Comments: ------------------------------------------------------------------------ [2021-02-13 09:34:40] mumumu@php.net Automatic comment on behalf of mumumu@mumumu.org Revision: http://git.php.net/?p=doc/ja.git;a=commit;h=b3ef2c18bac3cea8e6d0493723e54f7e2a92ab11 Log: Fix #69884: mysqli->connect_error seems to be shared across objects ------------------------------------------------------------------------ [2021-02-12 12:09:55] cmb@php.net Automatic comment on behalf of cmbecker69@gmx.de Revision: http://git.php.net/?p=doc/en.git;a=commit;h=efaedacb533200d9007d704d07e624b27c946036 Log: Fix #69884: mysqli->connect_error seems to be shared across objects ------------------------------------------------------------------------ [2021-02-12 12:09:08] cmb@php.net These are effectively static properties. ------------------------------------------------------------------------ [2020-10-19 09:58:58] call dot user dot func at gmail dot com Hi, this behaviour is the same in php8+. A warning in the docs would've been really helpful, as it's a pain to debug. A very brief testcase: $db1 = new MySQLi("localhost", "root", "", "mysql", 3306); var_dump("1: ".$db1->connect_error); // not error, db exist $db2 = new MySQLi("localhost", "root", "", "some_non_existing_db", 3306); var_dump("2: ".$db2->connect_error); // error, db not exist // db2 shared error to db1 which is wrong, db1 is still valid var_dump("3: ".$db1->connect_error); // not error, db exist ------------------------------------------------------------------------ [2018-08-14 02:54:13] requinix@php.net The values are indeed "shared", meaning the values are not associated with a specific instance but set globally. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=69884 -- Edit this bug report at https://bugs.php.net/bug.php?id=69884&edit=1

« previous php.doc.bugs (#18841) next »