Skip to content

Commit e8d41d1

Browse files
committed
Merge pull request #20 from phpcr/expressions
Added expr documentation for phpcr-shell
2 parents 193f3bf + d0ec504 commit e8d41d1

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

phpcr-shell/querying.rst

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ and are specific to PHPCRSH.
4646
any updates before hand in a development environment and ensure that you
4747
have a backup. We can take no responsibility for lost data!
4848

49+
50+
.. note::
51+
52+
UPDATE and DELETE operations are performed in userland and are based upon
53+
underlying SELECT operations, so any overhead incurred in an equivalent
54+
SELECT will be the baseline for UPDATE or DELETE overheads.
55+
4956
Updating
5057
--------
5158

@@ -169,6 +176,40 @@ Arguments:
169176
property
170177
- **value**: Value to append
171178

179+
expr
180+
""""
181+
182+
Evaluate an expression. This function is very powerful in that it enables
183+
you to use the `Symfony Expression Language`_ to evaluate an expression, the
184+
result of which can be assigned to a property.
185+
186+
Within the expression you have access to the `row` object
187+
(`RowInterface`_).
188+
189+
Set the value of ``a.title`` to the node name:
190+
191+
.. code-block:: bash
192+
193+
PHPCRSH> UPDATE [nt:unstructured] AS a SET a.title = expr('row.getNode().getName()')
194+
195+
Set the value of ``a.title`` to the value of the property :
196+
197+
.. code-block:: bash
198+
199+
PHPCRSH> UPDATE [nt:unstructured] AS a SET a.title = expr('row.getNode().getProperty('some_property')')
200+
201+
Increment the value of a property:
202+
203+
.. code-block:: bash
204+
205+
PHPCRSH> UPDATE [nt:unstructured] AS a SET a.count = expr('row.getNode().getPropertyValue("count") + 1')
206+
207+
Set the value of ``a.title`` from the value of a joined node:
208+
209+
.. code-block:: bash
210+
211+
PHPCRSH> UPDATE [nt:unstructured] AS a INNER JOIN [nt:something] AS b ON a.foo = b.bar SET a.title = expr('row.getNode("b").getPropertyValue("something")')
212+
172213
mixin_add
173214
"""""""""
174215
@@ -201,3 +242,6 @@ without the column selection:
201242
202243
PHPCRSH > DELETE FROM [slinpTest:article] WHERE title="Home"
203244
1 row(s) affected in 0.01s
245+
246+
.. _Symfony Expression Language: http://symfony.com/doc/current/components/expression_language/index.html
247+
.. _RowInterface: http://phpcr.github.io/doc/html/files/phpcr.src.PHPCR.Query.RowInterface.html#\PHPCR\Query\RowInterface

0 commit comments

Comments
 (0)