extending $db class

Is there a way for me to avoid having to add global $db to all of my little helper functions by making the helper functions extensions of $db in some way ?

eg. instead of
function deletelibrary ( $libid ) {
global $db;
$db->query("delete from library where id=$libid");
}

could I do something where I can just call
$db->deletelibrary( $libid );

?