Created
April 24, 2012 15:25
-
-
Save jpauli/2480585 to your computer and use it in GitHub Desktop.
Using mysqlnd stats to track development errors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class ComutoMysqli extends Mysqli | |
{ | |
public function __destruct() | |
{ | |
$stats = $this->get_connection_stats(); | |
$this->close(); | |
if($diff = $stats["rows_fetched_from_server_normal"] - ($stats["rows_fetched_from_client_normal_unbuffered"] + $stats["rows_fetched_from_client_normal_buffered"])) { | |
trigger_error("You didn't use *$diff* selected results, that's wasted!", E_USER_NOTICE); | |
} | |
} | |
} | |
$db = new ComutoMysqli(/* params */); | |
$result = mysqli_query($db,"SELECT user_id FROM users LIMIT 5"); | |
mysqli_data_seek($result, 5); | |
$data = mysqli_fetch_row($result); | |
/* Notice: You didn't use *4* selected results, that's wasted! */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment