当我尝试使用 GraphDb 查询结果在 php 中执行 addition/multiplication 等时,我得到下面的错误,不知道为什么。如果这很重要,在 GraphDb 中,值包含“^^ xsd:integer”。
$generalTotal = 0;
$sql = "PREFIX c: <http://chinde.ro#>
select ?titlu ?numeAutor ?pret ?nrBuc ((?pret * ?nrBuc) as $total) where {
GRAPH c:Vanzari {
?idV c:carte ?idCarte.
?idV c:bucati ?nrBuc.
?idV c:idTranz c:'.$idTranzactie.'.
}
GRAPH c:Carti {
?idCarte c:titlu ?titlu.
?idCarte c:autor ?idAutor.
?idCarte c:pret ?pret.
}
GRAPH c:Autori {
?idAutor c:numeAutor ?numeAutor.
}
}";
$res = $client->query($sql);
foreach($res as $row){
print "Total: ".$row->total;
$generalTotal = $generalTotal + $row->total; // <-- errors appears cause of this
}
print $generalTotal;
注意:在第 107 行的 C:\ xampp\htdocs\LICENTA2\admin\componenteAdmin\comenzi.php 中,类 EasyRdf_Literal_Integer 的对象无法转换为 int
我该怎么做?我应该创建一个子查询,从第一个查询中获取结果并将$total 的所有值添加到新参数中吗?或者是否有一种简单的方法可以使 php 识别查询?