You are here

function performance_db_get_data in Performance Logging and Monitoring 7

Same name and namespace in other branches
  1. 6 performance.module \performance_db_get_data()

Helper function to get data from the database.

Parameters

header table header array:

pager_height int num of rows per page:

time unix timestamp to start fetching data:

Return value

array of fetched data

2 calls to performance_db_get_data()
performance_get_data_db in ./performance.module
Wrapper function for consistency with the other data stores.
performance_view_summary in ./performance.module

File

./performance.module, line 866
Logs detailed and/or summary page generation time and memory consumption for page requests. Copyright Khalid Baheyeldin 2008 of http://2bits.com

Code

function performance_db_get_data($header, $pager_height, $timestamp = 0) {
  $data_list = array();

  // SQL: SELECT * FROM {performance_summary}
  $query = db_select('performance_summary', 'p')
    ->fields('p');
  if ($timestamp) {

    // SQL: WHERE last_access >= %d
    $query
      ->condition('last_access', $timestamp, '>=');
  }
  else {

    // Add pager and tablesort.
    $query
      ->extend('PagerDefault')
      ->limit($pager_height)
      ->extend('TableSort')
      ->orderByHeader($header);
  }

  // Run the query.
  $result = $query
    ->execute();
  foreach ($result as $row) {
    $data_list[] = $row;
  }
  return $data_list;
}