|
From: Markus S. <m.s...@hi...> - 2006-03-08 18:51:17
|
Hi again,
i fixed the problem in ../rap/api/sparql/SparqlEngine.php in method
_buildResultSet(). The problem was, that the value of $triple in the
foreach loop is a Statement object if queried against the default graph
and otherwise the value is a Quad object if queried against a named
graph. I hope this fits to your needs and is a real bugfix without
following a new bug!
regards, markus
/**
* Builds the resultset.
*
* @param GraphPattern $pattern
* @param Array $resmodel
* @return Array
*/
protected function _buildResultSet($pattern,$resmodel){
// determine variables and their corresponding values
$result = null;
if(is_string($pattern->getSubject())){
$n = 0;
foreach($resmodel['trip'] as $key => $triple){
if(isset($resmodel['graphvar'][$key]))
$result[$n][$resmodel['graphvar'][$key]] = $resmodel['graph'][$key];
// FIXED
if(isset($triple->subj)) {
$result[$n++][$pattern->getSubject()] = $triple->subj;
} else {
$result[$n++][$pattern->getSubject()] = $triple->statement->subj;
}
}
}
if(is_string($pattern->getPredicate())){
$n = 0;
foreach($resmodel['trip'] as $key => $triple){
if(isset($resmodel['graphvar'][$key]))
$result[$n][$resmodel['graphvar'][$key]] = $resmodel['graph'][$key];
// FIXED
if(isset($triple->pred)) {
$result[$n++][$pattern->getPredicate()] = $triple->pred;
} else {
$result[$n++][$pattern->getPredicate()] = $triple->statement->pred;
}
}
}
if(is_string($pattern->getObject())){
$n = 0;
foreach($resmodel['trip'] as $key => $triple){
if(isset($resmodel['graphvar'][$key]))
$result[$n][$resmodel['graphvar'][$key]] = $resmodel['graph'][$key];
// FIXED
if(isset($triple->obj)) {
$result[$n++][$pattern->getObject()] = $triple->obj;
} else {
$result[$n++][$pattern->getObject()] = $triple->statement->obj;
}
}
}
return $result;
}
|