You are here

function ARC_sparql_parser::parse_SelectQuery in Taxonomy import/export via XML 6.2

Same name and namespace in other branches
  1. 5.2 arc/ARC_sparql_parser.php \ARC_sparql_parser::parse_SelectQuery()
  2. 5 arc/ARC_sparql_parser.php \ARC_sparql_parser::parse_SelectQuery()
  3. 6 arc/ARC_sparql_parser.php \ARC_sparql_parser::parse_SelectQuery()

File

arc/ARC_sparql_parser.php, line 482

Class

ARC_sparql_parser

Code

function parse_SelectQuery() {

  /* distinct */
  $this->infos["distinct"] = false;
  if (preg_match("/^DISTINCT/i", $this->q, $matches)) {
    $this->infos["distinct"] = true;
    $this->q = trim(substr($this->q, strlen($matches[0])));
  }

  /* vars */
  $vars = $this
    ->extract_vars($this->q);
  $result_vars = array();

  /* result vars */
  if (preg_match("/^\\*(.*)\$/s", $this->q, $matches)) {

    /* * */
    $result_vars = $vars;
    $this->q = trim($matches[1]);
  }
  else {

    /* explicit var list */
    $q = $this->q;
    while (preg_match("/^[\\?\$]{1}([0-9a-z_]+)/i", $q, $matches)) {
      $result_vars[] = $matches[1];
      $this->logs[] = "adding result var " . $matches[1];
      $q = trim(substr($q, strlen($matches[0])));
    }
    $this->q = $q;
  }
  $this->infos["vars"] = $vars;
  $this->infos["result_vars"] = $result_vars;

  /* FROM */
  $this
    ->parse_DatasetClause();

  /* WHERE */
  $this
    ->parse_WhereClause();

  /* ORDER/LIMIT/OFFSET */
  $this
    ->parse_SolutionModifier();
}