You are here

protected function MysqlProfilerStorage::buildCriteria in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/http-kernel/Profiler/MysqlProfilerStorage.php \Symfony\Component\HttpKernel\Profiler\MysqlProfilerStorage::buildCriteria()

Build SQL criteria to fetch records by ip and url.

Parameters

string $ip The IP:

string $url The URL:

string $start The start period to search from:

string $end The end period to search to:

string $limit The maximum number of tokens to return:

string $method The request method:

Return value

array An array with (criteria, args)

Overrides PdoProfilerStorage::buildCriteria

File

vendor/symfony/http-kernel/Profiler/MysqlProfilerStorage.php, line 47

Class

MysqlProfilerStorage
A ProfilerStorage for Mysql.

Namespace

Symfony\Component\HttpKernel\Profiler

Code

protected function buildCriteria($ip, $url, $start, $end, $limit, $method) {
  $criteria = array();
  $args = array();
  if ($ip = preg_replace('/[^\\d\\.]/', '', $ip)) {
    $criteria[] = 'ip LIKE :ip';
    $args[':ip'] = '%' . $ip . '%';
  }
  if ($url) {
    $criteria[] = 'url LIKE :url';
    $args[':url'] = '%' . addcslashes($url, '%_\\') . '%';
  }
  if ($method) {
    $criteria[] = 'method = :method';
    $args[':method'] = $method;
  }
  if (!empty($start)) {
    $criteria[] = 'time >= :start';
    $args[':start'] = $start;
  }
  if (!empty($end)) {
    $criteria[] = 'time <= :end';
    $args[':end'] = $end;
  }
  return array(
    $criteria,
    $args,
  );
}