note 93021 modified in mysqli.get-warnings by danbrown

From: Date: Wed, 19 Aug 2009 21:05:00 +0000
Subject: note 93021 modified in mysqli.get-warnings by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-159659@lists.php.net to get a copy of this message
With a bit of rooting about with reflection, I spotted that the mysqli_warning class has a next() function, so I tried calling it and it does indeed progress through the available warnings! Following on from my earlier example: <?php $r = mysqli_query($db, "INSERT INTO blah SET z = '1'"); $j = mysqli_warning_count($db); if ($j > 0) { $e = mysqli_get_warnings($db); for ($i = 0; $i < $j; $i++) { var_dump($e); $e->next(); } } ?> This is a pretty rubbish interface - it's clearly a kind of half-baked iterable / traversable, but doesn't advertise those interfaces. It's actually more code than doing and processing a SHOW WARNINGS query manually! --was-- With a bit of rooting about with reflection, I spotted that the mysqli_warning class has a next() function, so I tried calling it and it does indeed progress through the available warnings! Following on from my earlier example: $r = mysqli_query($db, "INSERT INTO blah SET z = '1'"); $j = mysqli_warning_count($db); if ($j > 0) { $e = mysqli_get_warnings($db); for ($i = 0; $i < $j; $i++) { var_dump($e); $e->next(); } } This is a pretty rubbish interface - it's clearly a kind of half-baked iterable / traversable, but doesn't advertise those interfaces. It's actually more code than doing and processing a SHOW WARNINGS query manually! http://php.net/manual/en/mysqli.get-warnings.php

« previous php.notes (#159659) next »