Dear developers,
how can I run an SMW query from PHP?
I don't want any formatting, just an array of returned values.
I used to do it like that (ugly but working):
public function ask (array $args) {
list ($query, $params) =
SMWQueryProcessor::getQueryAndParamsFromFunctionParams (
$args,
SMW_OUTPUT_WIKI,
SMWQueryProcessor::INLINE_QUERY,
false
);
$queryResult = $params ['source']->getValue ()->getQueryResult
($query)->toArray () ['results'];
$result = [];
foreach ($queryResult as $page => $array) {
foreach ($array ['printouts'] as $label => $values) {
$value = is_array ($values [0]) ? $values [0]
['fulltext'] : $values [0];
$result [$page] [$label] = $value; // -- multiple
values later?
}
}
return [$result]; // -- lua for some reason needs arrays.
But after Validator or SMW was upgraded, I get an error: calling
getValue () on non-object (that is, $params ['source']).
Any ideas?
Alexander Mashin
------------------------------------------------------------------------------
_______________________________________________
Semediawiki-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/semediawiki-devel