Skip to content

Commit 3008cce

Browse files
committed
Updated
1 parent ae5e2b3 commit 3008cce

File tree

1 file changed

+46
-33
lines changed

1 file changed

+46
-33
lines changed

phpcr-shell/querying.rst

Lines changed: 46 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -59,35 +59,6 @@ The UPDATE Grammer extends the SELECT grammer:
5959
PHPCRSH > UPDATE [slinpTest:article] AS a LEFT JOIN [slinpTest:foobar] AS b ON a.uuid = b.content SET a.title="Away", b.title="Home" WHERE a.title="Home"
6060
1 row(s) affected in 0.01s
6161
62-
Multivalue indexes
63-
~~~~~~~~~~~~~~~~~~
64-
65-
You can update (or remove) specific multivalue indexes:
66-
67-
.. code-block:: bash
68-
69-
PHPCRSH > UPDATE [slinpTest:article] SET title[1] = "Away" WHERE title="Home"
70-
1 row(s) affected in 0.01s
71-
72-
The above query will set the multivalue value at index 1 to "Away" when the
73-
value "Home" matches *one of* the multivalue property values.
74-
75-
.. code-block:: bash
76-
77-
PHPCRSH > UPDATE [slinpTest:article] SET title[1] = NULL WHERE title="Home"
78-
1 row(s) affected in 0.01s
79-
80-
Same as above but the value at index 1 will be removed.
81-
82-
.. code-block:: bash
83-
84-
PHPCRSH > UPDATE [slinpTest:article] SET title[] = "Barfoo" WHERE title="Home"
85-
1 row(s) affected in 0.01s
86-
87-
The above will *add* the value "barfoo" to the multivalue properties (see also :ref:`phpcr_shell_query_function_arrayappend`)
88-
89-
See also: :ref:`phpcr_shell_query_function_arrayremove`, :ref:`phpcr_shell_query_function_arrayreplace`, :ref:`phpcr_shell_query_function_arrayappend`,
90-
9162
Functions
9263
~~~~~~~~~
9364

@@ -113,26 +84,68 @@ Arguments:
11384
property
11485
- **value**: Value to match and remove
11586

87+
.. _phpcr_shell_query_function_array:
88+
89+
array
90+
"""""
91+
92+
Provides an array value, analagous to the ``array`` keyword in PHP:
93+
94+
.. code-block:: bash
95+
96+
PHPCRSH> UPDATE [nt:unstructured] SET tags = array('One', 'Two', 'Three')
97+
98+
Arguments:
99+
100+
- List of values
101+
116102
.. _phpcr_shell_query_function_arrayreplace:
117103

118104
array_replace
119105
"""""""""""""
120106

121-
Replace a given multivalue property value.
107+
Replace a given multivalue property value, or remove it by setting it to
108+
``NULL``.
122109

123-
Usage:
110+
Replace a value:
124111

125112
.. code-block:: bash
126113
127-
PHPCRSH> UPDATE [nt:unstructured] SET tags = array_replace(tags, 'Planes', 'Rockets') WHERE tags = 'Planes'
114+
PHPCRSH> UPDATE [nt:unstructured] SET tags = array_replace(tags, 'Planes', 'Rockets')
115+
116+
Remove matching values:
117+
118+
.. code-block:: bash
119+
120+
PHPCRSH> UPDATE [nt:unstructured] SET tags = array_replace(tags, 'Planes', NULL)
128121
129122
Arguments:
130123

131124
- **propertyName**: Property name (including selector) of the multivalue
132125
property
133-
- **value**: Value to replace
126+
- **value**: Value to replace, use ``NULL`` to remove a value
134127
- **replacement**: Replacement value
135128

129+
.. _phpcr_shell_query_function_arrayreplaceat:
130+
131+
array_replace_at
132+
""""""""""""""""
133+
134+
Replace a given multivalue property value at the specified index.
135+
136+
Usage:
137+
138+
.. code-block:: bash
139+
140+
PHPCRSH> UPDATE [nt:unstructured] SET tags = array_replace_at(tags, 0, 'Rockets') WHERE tags = 'Planes'
141+
142+
Arguments:
143+
144+
- **propertyName**: Property name (including selector) of the multivalue
145+
property
146+
- **index**: Index at which the new value should be set
147+
- **value**: Value to set
148+
136149
.. _phpcr_shell_query_function_arrayappend:
137150

138151
array_append

0 commit comments

Comments
 (0)