File: 036.solrdocument_array_access.phpt

package info (click to toggle)
php-solr 2.6.0%2B2.4.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 4,956 kB
  • sloc: ansic: 40,168; xml: 2,223; php: 1,987; pascal: 8; makefile: 3
file content (57 lines) | stat: -rw-r--r-- 1,067 bytes parent folder | download | duplicates (3)
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
--TEST--
SolrDocument - Array Access
--FILE--
<?php

require_once "bootstrap.inc";
$doc = new SolrDocument();

$doc->addField('id', 334455);
$doc->addField('manu_id_s', 'apache');
// set
$doc['cat'] = 'Software';

// get
var_dump($doc['cat']->values[0]);

// exists
var_dump(isset($doc['cat']));

// unset
unset($doc['cat']);
print_r($doc->toArray());
?>
--EXPECT--
string(8) "Software"
bool(true)
Array
(
    [document_boost] => 0
    [field_count] => 2
    [fields] => Array
        (
            [0] => SolrDocumentField Object
                (
                    [name] => id
                    [boost] => 0
                    [values] => Array
                        (
                            [0] => 334455
                        )

                )

            [1] => SolrDocumentField Object
                (
                    [name] => manu_id_s
                    [boost] => 0
                    [values] => Array
                        (
                            [0] => apache
                        )

                )

        )

)