#49298 [Opn]: mysqli_get_warnings isn't much use

From: Date: Wed, 19 Aug 2009 19:26:29 +0000
Subject: #49298 [Opn]: mysqli_get_warnings isn't much use
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-141259@lists.php.net to get a copy of this message
ID: 49298 User updated by: marcus at synchromedia dot co dot uk -Summary: mysqli_show_warnings isn't much use Reported By: marcus at synchromedia dot co dot uk Status: Open Bug Type: MySQLi related PHP Version: 5.3.0 New Comment: Sorry, misnamed function in title Previous Comments: ------------------------------------------------------------------------ [2009-08-19 14:15:26] marcus at synchromedia dot co dot uk Description: ------------ mysqli_get_warnings only ever returns a single warning, even if more than one is available. Though its name implies a plural response, it doesn't deliver one. Reproduce code: --------------- Do this in a mysql CLI: CREATE TABLE blah ( x varchar(100) NOT NULL, y varchar(100) NOT NULL, z varchar(100) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=latin1; INSERT INTO blah SET z = '1'; Query OK, 1 row affected, 2 warnings (0.00 sec) mysql> show warnings; +---------+------+----------------------------------------+ | Level | Code | Message | +---------+------+----------------------------------------+ | Warning | 1364 | Field 'x' doesn't have a default value | | Warning | 1364 | Field 'y' doesn't have a default value | +---------+------+----------------------------------------+ Now do the same insert from PHP then call mysqli_get_warnings() (approximate code): mysqli_query($db, "INSERT INTO blah SET z = '1'"); $a = mysqli_get_warnings($db); var_dump($a); Expected result: ---------------- I'd want something like this: array (2) { object(mysqli_warning)#4 (3) { ["message"]=> string(38) "Field 'x' doesn't have a default value" ["sqlstate"]=> string(5) "HY000" ["errno"]=> int(1364) }, object(mysqli_warning)#5 (3) { ["message"]=> string(38) "Field 'y' doesn't have a default value" ["sqlstate"]=> string(5) "HY000" ["errno"]=> int(1364) } } Actual result: -------------- object(mysqli_warning)#4 (3) { ["message"]=> string(38) "Field 'x' doesn't have a default value" ["sqlstate"]=> string(5) "HY000" ["errno"]=> int(1364) } ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=49298&edit=1

« previous php.bugs (#141259) next »