Example #1
0
 public function optimize(Erfurt_Sparql_Query $query)
 {
     $resultForm = $query->getResultForm();
     $result = $query;
     // TODO Not working on all queries yet.
     #return $result;
     if ($resultForm === 'select distinct') {
         $result = $this->_optimizeDistinct($query);
     }
     return $result;
 }
Example #2
0
 public static function getSelect(Erfurt_Sparql_Query $query, $arSqls, $strAdditional = '')
 {
     if (count($arSqls) == 1) {
         return implode('', $arSqls[0]) . $strAdditional;
     }
     //union
     $strUnion = 'UNION' . ($query->getResultForm() == 'select distinct' ? '' : ' ALL');
     $ar = array();
     foreach ($arSqls as $arSql) {
         $ar[] = implode('', $arSql) . $strAdditional;
     }
     return '(' . implode(') ' . $strUnion . ' (', $ar) . ')';
 }
Example #3
0
 /** Adds a new variable to the query and sets result form to 'DESCRIBE'. */
 protected function _parseDescribe()
 {
     while (strtolower(current($this->_tokens)) != 'from' && strtolower(current($this->_tokens)) != 'where') {
         $this->_fastForward();
         if ($this->_varCheck(current($this->_tokens)) || $this->_iriCheck(current($this->_tokens))) {
             require_once 'Erfurt/Sparql/QueryResultVariable.php';
             $var = new Erfurt_Sparql_QueryResultVariable(current($this->_tokens));
             $this->_query->addResultVar($var);
             if (!$this->_query->getResultForm()) {
                 $this->_query->setResultForm('describe');
             }
         }
         if (!current($this->_tokens)) {
             break;
         }
     }
     prev($this->_tokens);
 }