Or you can use the API. Don't do manual queries, chances are 99% you can do it all without touching the API.
I'm re-vamping for statistics, to add a flexible query system like I added for PIREPS and Schedules and Pilots, but for now, you can do this (which actually is using the PIREP query system, this shows how flexible it is)
<?php
$params = array(
'p.pilotid' => [pilotid],
'p.registration' => [aircraft registration],
);
// Look for the last 24 months
$totals = PIREPData::getIntervalDataByMonth($params, 24);
$flown_time = 0;
foreach($totals as $total)
{
$flown_time = Util::AddTime($flown_time, $total->total);
}
echo 'Total time flown: '.$flown_time;
It'll be a bit slow, but I'm working on better functions for statistics as part of the cleanup. It might not work completely, but I'll let you figure out the pieces. You can put that in a loop for each aircraft