-
Notifications
You must be signed in to change notification settings - Fork 5
Added dedicated querying chapter #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,6 @@ PHPCR-Shell | |
installation | ||
connecting | ||
interacting | ||
querying | ||
configuration | ||
reference |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
Querying | ||
======== | ||
|
||
Selecting | ||
--------- | ||
|
||
PHPCRSH currently supports the JCR-SQL2 query language when supported by the | ||
implementation (currently all implementations support this language). | ||
|
||
.. code-block:: bash | ||
|
||
PHPCRSH > SELECT title FROM slinpTest:article | ||
+--------------------------------------------+-----------------------------+ | ||
| Path | slinpTest:article.title | | ||
+--------------------------------------------+-----------------------------+ | ||
| /slinp/web/root | Slinp Web Content Framework | | ||
| /slinp/web/root/home | Home | | ||
| /slinp/web/root/articles/Faster-than-light | Faster than light | | ||
+--------------------------------------------+-----------------------------+ | ||
3 rows in set (0.01 sec) | ||
|
||
PHPCRSH > SELECT title FROM slinpTest:article WHERE title="Home" | ||
+----------------------+-------------------------+ | ||
| Path | slinpTest:article.title | | ||
+----------------------+-------------------------+ | ||
| /slinp/web/root/home | Home | | ||
+----------------------+-------------------------+ | ||
1 rows in set (0.04 sec) | ||
|
||
The JCR-SQL2 lanugage supports joins, column selection and a range of | ||
operands (e.g. lowercase, uppercase, length, etc). | ||
|
||
For more information on JCR-SQL2 refer to the articles on the | ||
`official PHPCR website <http://phpcr.github.io/documentation/>`_. | ||
|
||
Update and Delete | ||
----------------- | ||
|
||
In addition to standard support for SELECT queries, PHPCRSH additionally | ||
supports UPDATE and DELETE queries, these query grammers **are not standard** | ||
and are specific to PHPCRSH. | ||
|
||
.. note:: | ||
|
||
UPDATE and DELETE operations are *experimental*. You are advised to test | ||
any updates before hand in a development environment and ensure that you | ||
have a backup. We can take no responsibility for lost data! | ||
|
||
Updating | ||
-------- | ||
|
||
The UPDATE Grammer extends the SELECT grammer: | ||
|
||
.. code-block:: bash | ||
|
||
PHPCRSH > UPDATE [slinpTest:article] SET title="Away" WHERE title="Home" | ||
1 row(s) affected in 0.01s | ||
|
||
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" | ||
1 row(s) affected in 0.01s | ||
|
||
Multivalue indexes | ||
~~~~~~~~~~~~~~~~~~ | ||
|
||
You can update (or remove) specific multivalue indexes: | ||
|
||
.. code-block:: bash | ||
|
||
PHPCRSH > UPDATE [slinpTest:article] SET title[1] = "Away" WHERE title="Home" | ||
1 row(s) affected in 0.01s | ||
|
||
The above query will set the multivalue value at index 1 to "Away" when the | ||
value "Home" matches *one of* the multivalue property values. | ||
|
||
.. code-block:: bash | ||
|
||
PHPCRSH > UPDATE [slinpTest:article] SET title[1] = NULL WHERE title="Home" | ||
1 row(s) affected in 0.01s | ||
|
||
Same as above but the value at index 1 will be removed. | ||
|
||
.. code-block:: bash | ||
|
||
PHPCRSH > UPDATE [slinpTest:article] SET title[] = "Barfoo" WHERE title="Home" | ||
1 row(s) affected in 0.01s | ||
|
||
The above will *add* the value "barfoo" to the multivalue properties (see also :ref:`phpcr_shell_query_function_arrayappend`) | ||
|
||
See also: :ref:`phpcr_shell_query_function_arrayremove`, :ref:`phpcr_shell_query_function_arrayreplace`, :ref:`phpcr_shell_query_function_arrayappend`, | ||
|
||
Functions | ||
~~~~~~~~~ | ||
|
||
The ``UPDATE`` grammer also allows the use of functions (note that only UPDATE | ||
supports functions). | ||
|
||
.. _phpcr_shell_query_function_arrayremove: | ||
|
||
array_remove | ||
"""""""""""" | ||
|
||
Remove the multivalue property value matching the given value. | ||
|
||
Usage: | ||
|
||
.. code-block:: bash | ||
|
||
PHPCRSH> UPDATE [nt:unstructured] AS a SET a.tags = array_remove(a.tags, 'Planes') WHERE a.tags = 'Planes' | ||
|
||
Arguments: | ||
|
||
- **propertyName**: Property name (including selector) of the multivalue | ||
property | ||
- **value**: Value to match and remove | ||
|
||
.. _phpcr_shell_query_function_arrayreplace: | ||
|
||
array_replace | ||
""""""""""""" | ||
|
||
Replace a given multivalue property value. | ||
|
||
Usage: | ||
|
||
.. code-block:: bash | ||
|
||
PHPCRSH> UPDATE [nt:unstructured] SET tags = array_replace(tags, 'Planes', 'Rockets') WHERE tags = 'Planes' | ||
|
||
Arguments: | ||
|
||
- **propertyName**: Property name (including selector) of the multivalue | ||
property | ||
- **value**: Value to replace | ||
- **replacement**: Replacement value | ||
|
||
.. _phpcr_shell_query_function_arrayappend: | ||
|
||
array_append | ||
"""""""""""" | ||
|
||
Append a value to a multivalue property. | ||
|
||
Usage: | ||
|
||
.. code-block:: bash | ||
|
||
PHPCRSH> UPDATE [nt:unstructured] SET tags - array_append(tags, 'Planes') WHERE tags = 'Planes' | ||
|
||
Arguments: | ||
|
||
- **propertyName**: Property name (including selector) of the multivalue | ||
property | ||
- **value**: Value to append | ||
|
||
Deleting | ||
-------- | ||
|
||
Delete is as you might expect, and is essentially gramatically identical to ``SELECT`` but | ||
without the column selection: | ||
|
||
.. code-block:: bash | ||
|
||
PHPCRSH > DELETE FROM [slinpTest:article] WHERE title="Home" | ||
1 row(s) affected in 0.01s |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn't that a reference to this doc again? or are there only the java documentations for that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there are external links to java related stuff