You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: phpcr-shell/querying.rst
+46-33Lines changed: 46 additions & 33 deletions
Original file line number
Diff line number
Diff line change
@@ -59,35 +59,6 @@ The UPDATE Grammer extends the SELECT grammer:
59
59
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"
60
60
1 row(s) affected in 0.01s
61
61
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
-
91
62
Functions
92
63
~~~~~~~~~
93
64
@@ -113,26 +84,68 @@ Arguments:
113
84
property
114
85
- **value**: Value to match and remove
115
86
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
+
116
102
.. _phpcr_shell_query_function_arrayreplace:
117
103
118
104
array_replace
119
105
"""""""""""""
120
106
121
-
Replace a given multivalue property value.
107
+
Replace a given multivalue property value, or remove it by setting it to
108
+
``NULL``.
122
109
123
-
Usage:
110
+
Replace a value:
124
111
125
112
.. code-block:: bash
126
113
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)
128
121
129
122
Arguments:
130
123
131
124
- **propertyName**: Property name (including selector) of the multivalue
132
125
property
133
-
- **value**: Value to replace
126
+
- **value**: Value to replace, use ``NULL`` to remove a value
134
127
- **replacement**: Replacement value
135
128
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
0 commit comments