[eluser]tonanbarbarian[/eluser]
the only way that $CI->db is undefined is if the database has not been loaded, or if some processes has unset the db property.
is your database autoloaded? (i would suggest probably not)
if the helper being called in an instance in which the database has not been previously loaded?