summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticMediaWiki/docs/technical/code-snippets/match.property.values.md
diff options
context:
space:
mode:
Diffstat (limited to 'www/wiki/extensions/SemanticMediaWiki/docs/technical/code-snippets/match.property.values.md')
-rw-r--r--www/wiki/extensions/SemanticMediaWiki/docs/technical/code-snippets/match.property.values.md63
1 files changed, 63 insertions, 0 deletions
diff --git a/www/wiki/extensions/SemanticMediaWiki/docs/technical/code-snippets/match.property.values.md b/www/wiki/extensions/SemanticMediaWiki/docs/technical/code-snippets/match.property.values.md
new file mode 100644
index 00000000..87fd6761
--- /dev/null
+++ b/www/wiki/extensions/SemanticMediaWiki/docs/technical/code-snippets/match.property.values.md
@@ -0,0 +1,63 @@
+Examples listed in this document require SMW 2.5.
+
+```php
+use SMW\ApplicationFactory;
+
+$applicationFactory = ApplicationFactory::getInstance();
+$queryFactory = $applicationFactory->getQueryFactory();
+
+$dataItemFactory = $applicationFactory->getDataItemFactory();
+
+$dataValue = $applicationFactory->getDataValueFactory()->newDataValueByProperty(
+ $dataItemFactory->newDIProperty( 'Foo' ),
+ 'Bar'
+);
+```
+```php
+$requestOptions = $queryFactory->newRequestOptions();
+$requestOptions->setLimit( 42 );
+
+// Find subjects that match [[Foo::Bar]] and limit the return results to 42
+$subjectList = $applicationFactory->getStore()->getPropertySubjects(
+ $dataValue->getProperty(),
+ $dataValue->getDataItem(),
+ $requestOptions
+);
+```
+```php
+$requestOptions = $queryFactory->newRequestOptions();
+$requestOptions->setLimit( 42 );
+
+// Find all subjects that have a Property:Foo assigned and limit the return results to 42
+$subjectList = $applicationFactory->getStore()->getAllPropertySubjects(
+ $dataValue->getProperty(),
+ $requestOptions
+);
+```
+```php
+$descriptionFactory = $queryFactory->newDescriptionFactory();
+
+// Query [[Foo::+]] with a limit of 42 matches
+$description = $descriptionFactory->newSomeProperty(
+ $dataValue->getProperty(),
+ $descriptionFactory->newThingDescription()
+);
+
+$query = $queryFactory->newQuery( $description );
+$query->setLimit( 42 );
+
+$queryResult = $applicationFactory->getStore()->getQueryResult( $query );
+```
+```php
+$descriptionFactory = $queryFactory->newDescriptionFactory();
+
+// [[Foo::Bar]] with a limit of 42 matches
+$description = $descriptionFactory->newFromDataValue(
+ $dataValue
+);
+
+$query = $queryFactory->newQuery( $description );
+$query->setLimit( 42 );
+
+$queryResult = $applicationFactory->getStore()->getQueryResult( $query );
+```