$EZSQL_ERROR doesn't work

I’m having some difficulty with getting $EZSQL_ERROR to work. In the following snippet, the error message should be displayed, but it’s not, just blank output. Other times I get an error that the $EZSQL_ERROR variable doesn’t exist.

if($sql = $db->get_results("this is a bad query", ARRAY_A)) {
	// do nothing as we are getting an error
} else {
	if($EZSQL_ERROR) {
		echo 'this is the ezsql error message';
	}
}

Doesn’t anybody have experience with this?

What’s wrong with using…

if(!$sql){
echo ‘this is the ezsql error message’;
}

??

Well, that doesn’t necessarily tell me there was an error, just that there were no results from the query.