Execute PHP function inside the admin area

Hook into the admin_init action…

add_action('admin_init', 'fetch_all_companies');

function fetch_all_companies() {
    //do something here...
}

note:

What file are you running your fetch_all_companies() function from and where is it located (the path to the file)? Its likely the WordPress environment is not loaded on the destination file which is why your function appears to be undefined.