Skip to content

Instantly share code, notes, and snippets.

@jpauli
Created April 24, 2012 15:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jpauli/2480585 to your computer and use it in GitHub Desktop.
Save jpauli/2480585 to your computer and use it in GitHub Desktop.
Using mysqlnd stats to track development errors
<?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