MySQL View无法通过shell命令执行

I have a PHP script (CakePHP framework) that makes this call

$data_reports = Cache::read('get_data_reports', 'short');
if (!$data_reports) {
    $data_reports = $this->paginate('DataReport');
    Cache::write('get_data_reports', $data_reports, 'short');
}

where DataReport model uses a View named data_report_v in the database.

When executing the script via the browser, it works fine - I got data being returned and cached.

However, if I execute the script from the shell, retrieving data from data_report_v view won't work. Also, if I replace that view call with the actual query (that is wrapped within the view itself), the shell command can now execute that and return results.

What is the problem here?