I am using Semantic MediaWiki and am also developing another custom extension. I would like to query semantic values directly in PHP; i.e., something like:
SemanticMediaWiki::ask('PAGE_NAME', 'FIELD_NAME')
However, I cannot seem to find any documentation of this being possible. I know there is an Ask API, but this documents only querying using a URL, not a direct PHP query. I also know that I can include "ask" references inside pages via inline queries. However, what I want to do is query semantic values directly inside the PHP of my custom extension.
Does anyone know whether I can directly query a semantic value from PHP?
You can also use https://github.com/vedmaka/SemanticQueryInterface - it is a wrapper around SMW internal API which allows you to do things like that:
$results = $sqi->condition("My property", "My value")->toArray();
See more at https://www.mediawiki.org/wiki/User:Vedmaka/Semantic_Query_Interface