Source for file Offsetter.php
Documentation is available at Offsetter.php
require_once RDFAPI_INCLUDE_DIR .
'sparql/SparqlEngineDb/SqlMerger.php';
* Determines the offset in a row of sql queries.
* @author Christian Weiske <cweiske@cweiske.de>
public function __construct(ADOConnection $dbConn, Query $query)
}//public function __construct(ADOConnection $dbConn, Query $query)
* Determines the offset in the sqls, the position to start form.
* @param array $arSqls Array of SQL query parts as returned by
* SparqlEngine_TypeSorter::getOrderifiedSqls()
* @return array Array of two values: The first determines the
* index of the sql query to begin with, the second
* is the row offset that should be used in the final
$arSM =
$this->query->getSolutionModifier();
if ($arSM['offset'] ===
null) {
foreach ($arSqls as $nId =>
$arSql) {
$nCurrentCount =
$this->getCount($arSql);
if ($nCurrentCount +
$nCount >
$arSM['offset']) {
return array($nId, $arSM['offset'] -
$nCount);
$nCount +=
$nCurrentCount;
//nothing found - no results for this offset
return array(count($arSqls), 0);
}//public function determineOffset($arSql)
* Returns the number of rows that the given query will return.
* @param array $arSql Array with sql parts and at least keys
* 'from' and 'where' set.
* @return int Number of rows returned.
$dbResult =
$this->dbConn->execute($sql);
foreach ($dbResult as $row) {
}//protected function getCount($arSql)
* Creates a sql LIMIT statement if the sparql query needs one.
* This method is needed because AdoDb does not support limits with
* prepared statements. It's a pity.
* @return string SQL command to be appended to a query, to limit
* the number of result rows returned.
public static function getLimitSql(Query $query, ADOConnection $dbConn)
$arSM =
$query->getSolutionModifier();
if ($arSM['limit'] ===
null &&
$arSM['offset'] ===
null) {
//this here is mysql syntax. if anyone has problems, write it
//dependent on $dbConn's type
if ($arSM['offset'] ===
null) {
return ' LIMIT ' .
$arSM['limit'];
} else if ($arSM['limit'] ===
null) {
return ' LIMIT ' .
$arSM['offset'] .
', 18446744073709551615';
return ' LIMIT ' .
$arSM['offset'] .
', ' .
$arSM['limit'];
}//public static function getLimitSql(Query $query, ADOConnection $dbConn)
}//class SparqlEngineDb_Offsetter
Documentation generated on Fri, 1 Jun 2007 16:50:05 +0200 by phpDocumentor 1.3.2