summaryrefslogtreecommitdiff
path: root/www/wiki/extensions/SemanticMediaWiki/docs/technical/code-snippets/match.property.values.md
blob: 87fd676120275a85d43c1cdf4119c8accd951f78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
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 );
```