Beispiel #1
0
 /**
  *   Converts the given queries into sql prepared statments,
  *   calls the prepare command in the database and returns
  *   an array consisting of subarrays. They contain
  *   the db's prepared statement as first value, and an array
  *   of variable positions as second value (key is the position,
  *   the sparql variable is the value).
  *
  *   @param array $arQueries      Array of sql queries part arrays
  *   @param array $arPlaceholders Array of sparql (variable name =>
  *                                placeholder name) pairs
  *   @return array  Array of (prepared statment, variable positions) pairs
  */
 public function prepareInDb($arQueries, $arPlaceholders)
 {
     $arDbStatements = array();
     foreach ($arQueries as $arQuery) {
         list($strPrepared, $arVariablePositions) = $this->replacePlaceholders(implode('', $arQuery), $arPlaceholders);
         if (count($arQueries) == 1) {
             //I currently haven't seens one case in which the count was > 1
             //if that happens, we will need to add a fix
             $strPrepared .= SparqlEngineDb_Offsetter::getLimitSql($this->query, $this->dbConn);
         }
         $stmt = $this->dbConn->Prepare($strPrepared);
         $arDbStatements[] = array($stmt, $arVariablePositions);
     }
     return $arDbStatements;
 }
Beispiel #2
0
 /**
  *   Executes multiple SQL queries and returns an array
  *   of results.
  *
  *   @param array $arSqls     Array of SQL queries
  *   @return array   Array of query results
  */
 protected function queryMultiple($arSqls)
 {
     $arSM = $this->query->getSolutionModifier();
     if ($arSM['limit'] === null && $arSM['offset'] === null) {
         $nOffset = 0;
         $nLimit = null;
         $nSql = 0;
     } else {
         $offsetter = new SparqlEngineDb_Offsetter($this->dbConn, $this->query);
         list($nSql, $nOffset) = $offsetter->determineOffset($arSqls);
         $nLimit = $arSM['limit'];
     }
     $nCount = 0;
     $arResults = array();
     foreach ($arSqls as $nId => $arSql) {
         if ($nId < $nSql) {
             continue;
         }
         if ($nLimit != null) {
             $nCurrentLimit = $nLimit - $nCount;
         } else {
             $nCurrentLimit = null;
         }
         $dbResult = $this->queryDb($arSql, $nOffset, $nCurrentLimit);
         $nCount += $dbResult->RowCount();
         $arResults[] = $dbResult;
         $nOffset = 0;
         if ($nLimit !== null && $nCount >= $nLimit) {
             break;
         }
     }
     return $arResults;
     //return array_map(array($this, 'queryDb'), $arSql);
 }