Skip to content

Instantly share code, notes, and snippets.

Created September 5, 2013 16:21
Show Gist options
  • Save anonymous/6452479 to your computer and use it in GitHub Desktop.
Save anonymous/6452479 to your computer and use it in GitHub Desktop.
PHPCR QB Abbreviations

With abbreviation

        $this->node
            ->select()
                ->prop('foobar', 'a') // instead of property()
                ->prop('barfoo', 'a')
            ->end()
            ->addSelect()
                ->prop('foobar', 'a')
                ->prop('barfoo', 'a')
            ->end()
            ->from()
                ->joinInner()
                    ->left()->doc('foobar', 'a')->end()
                    ->right()->doc('barfoo', 'b')->end()
                    ->condition()->equi('prop_1', 'a', 'prop_2', 'b')->end()
                ->end()
            ->end()
            ->fromDoc('foobar', 'a')
            ->addJoinInner()
                ->right()->document('foobar', 'a')->end()
                ->condition()->equi('prop_1', 'a', 'prop_2', 'b')->end()
            ->end()
            ->addJoinLeftOuter()
                ->right()->doc('foobar', 'a')->end()
                ->condition()->equi('prop_1', 'a', 'prop_2', 'b')->end()
            ->end()
            ->addJoinRightOuter()
                ->right()->doc('foobar', 'a')->end() // instead of document()
                ->condition()->equi('prop_1', 'a', 'prop_2', 'b')->end()
            ->end()
            ->where()
                ->andX()
                    ->eq()
                        ->propVal('foobar', 'a') // instead of propertyValue() or even just prop() ?
                        ->literal('foo_value')
                    ->end()
                    ->like()
                        ->docName('my_doc')
                        ->bindVar('my_var') // instead of bindVariable
                    ->end()
                ->end()
            ->end()
            ->andWhere()
                ->propExists('sel_1', 'foobar') // instead of propertyExists
            ->end()
            ->orWhere()
                ->propExists('sel_1', 'foobar')
            ->end()
            ->orderBy()
                ->asc()->docName('a')->end() // instead of ascending()->documentName
                ->desc()->docName('b')->end() // instead of descending()->documentName
            ->end()
            ->addOrderBy()
                ->asc()->docName('c')->end()
            ->end();

Sans abreviation

        $this->node
            ->select()
                ->property('foobar', 'a')
                ->property('barfoo', 'a')
            ->end()
            ->addSelect()
                ->property('foobar', 'a')
                ->property('barfoo', 'a')
            ->end()
            ->from()
                ->joinInner()
                    ->left()->document('foobar', 'a')->end()
                    ->right()->document('barfoo', 'b')->end()
                    ->condition()->equi('prop_1', 'a', 'prop_2', 'b')->end()
                ->end()
            ->end()
            ->fromDocument('foobar', 'a')
            ->addJoinInner()
                ->right()->document('foobar', 'a')->end()
                ->condition()->equi('prop_1', 'a', 'prop_2', 'b')->end()
            ->end()
            ->addJoinLeftOuter()
                ->right()->document('foobar', 'a')->end()
                ->condition()->equi('prop_1', 'a', 'prop_2', 'b')->end()
            ->end()
            ->addJoinRightOuter()
                ->right()->document('foobar', 'a')->end()
                ->condition()->equi('prop_1', 'a', 'prop_2', 'b')->end()
            ->end()
            ->where()
                ->andX()
                    ->eq()
                        ->propertyValue('foobar', 'a')
                        ->literal('foo_value')
                    ->end()
                    ->like()
                        ->documentName('my_doc')
                        ->bindVariable('my_var')
                    ->end()
                ->end()
            ->end()
            ->andWhere()
                ->propertyExists('sel_1', 'foobar')
            ->end()
            ->orWhere()
                ->propertyExists('sel_1', 'foobar')
            ->end()
            ->orderBy()
                ->ascending()->documentName('a')->end()
                ->descending()->documentName('b')->end()
            ->end()
            ->addOrderBy()
                ->ascending()->documentName('c')->end()
            ->end();

Method by method

- **addJoinInner()**: 
- **addJoinLeftOuter()**: 
- **addJoinRightOuter()**: 
- **addOrderBy()**: 
- **addSelect()**: 
- **andWhere()**: 
- **andX()**: 
- **ascending()**: 
- **bindVariable($name)**: 
- **childDocument($selectorName, $parentPath)**: 
- **descendantDocument($selectorName, $ancestorPath)**: 
- **descending()**: 
- **document($documentFqn, $selectorName)**: 
- **documentLocalName($selectorName)**: 
- **documentName($selectorName)**: 
- **eq()**: 
- **from()**: 
- **fullTextSearchScore($selectorName)**: 
- **fullTextSearch($selectorName, $propertyName, $fullTextSearchExpression)**: 
- **gt()**: 
- **gte()**: 
- **joinInner()**: 
- **joinLeftOuter()**: 
- **joinRightOuter()**: 
- **length($selectorName, $propertyName)**: 
- **like()**: 
- **literal($value)**: 
- **lowerCase()**: 
- **lt()**: 
- **lte()**: 
- **neq()**: 
- **not()**: 
- **orderBy()**: 
- **orWhere()**: 
- **orX()**: 
- **propertyExists($selectorName, $propertyName)**: 
- **property($selectorName, $propertyName)**: 
- **propertyValue($selectorName, $propertyName)**: 
       -> ** recursion **
   -> ** recursion **
- **sameDocument($selectorName, $path)**: 
- **select()**: 
- **upperCase()**: 
- **where()**: 
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment