class WhereOr extends Where (View source)

Factory node for appending additional "wheres" with an OR.

Constants

NT_BUILDER

NT_CONSTRAINT

NT_CONSTRAINT_FACTORY

NT_FROM

NT_OPERAND_DYNAMIC

NT_OPERAND_DYNAMIC_FACTORY

NT_OPERAND_STATIC

NT_OPERAND_FACTORY

NT_ORDERING

NT_ORDER_BY

NT_PROPERTY

NT_SELECT

NT_SOURCE

NT_SOURCE_FACTORY

NT_SOURCE_JOIN_CONDITION

NT_SOURCE_JOIN_CONDITION_FACTORY

NT_SOURCE_JOIN_LEFT

NT_SOURCE_JOIN_RIGHT

NT_WHERE

NT_WHERE_AND

NT_WHERE_OR

Properties

protected $children from AbstractNode
protected $parent from AbstractNode

Methods

__construct(AbstractNode $parent = null)

No description

string
getNodeType()

Return the type of node.

getParent()

Return the parent of this node.

string
getName()

Return the last part of the this classes FQN (i.e. the basename).

array
getCardinalityMap()

Return the cardinality map for this node.

setChild(AbstractNode $node)

Remove any previous children and add given node via. addChild.

addChild(AbstractNode $node)

Add a child to this node.

getNext()

Return the next object in the fluid interface chain. Leaf nodes always return the parent, deafult behavior is to return /this/ class.

getChildren()

Return all child nodes.

getChildrenOfType(string $type)

Return children of specified type.

removeChildrenOfType($type)

No description

getChild()

Return child of node, there must be exactly one child of any type.

getChildOfType(string $type)

Return child of specified type.

validate()

Validate the current node.

end()

Validates this node and returns its parent.

__call(string $methodName, array $args)

Catch any undefined method calls and tell the developer what methods can be called.

ensureNoArguments($method, $void)

No description

getFactoryMethods()

No description

andX()

And composite constraint::.

orX()

Or composite constraint::.

fieldIsset(string $field)

Field existance constraint::.

fullTextSearch(string $field, string $fullTextSearchExpression)

Full text search constraint::.

same(string $path, string $alias)

Same document constraint::.

descendant(string $ancestorPath, string $alias)

Descendant document constraint::.

child(string $parentPath, string $alias)

Select children of the aliased document at the given path::.

not()

Inverts the truth of the given appended constraint.

eq()

Equality comparison constraint::.

neq()

Inequality comparison constraint::.

lt()

Less than comparison constraint::.

lte()

Less than or equal to comparison constraint::.

gt()

Greater than comparison constraint::.

gte()

Greater than or equal to comparison constraint::.

like()

Like comparison constraint.

Details

__construct(AbstractNode $parent = null)

Parameters

AbstractNode $parent

string getNodeType()

Return the type of node.

Must be one of self::NT_*

Return Value

string

AbstractNode getParent()

Return the parent of this node.

Return Value

AbstractNode

final string getName()

Return the last part of the this classes FQN (i.e. the basename).

This should only be used when generating exceptions This is also used to determine the dispatching method -- should it be?

Return Value

string

array getCardinalityMap()

Return the cardinality map for this node.

e.g. array( self::NT_JOIN_CONDITION => array(1, 1), // require exactly 1 join condition self::NT_SOURCE => array(2, 2), // exactly 2 sources );

or: array( self::NT_PROPERTY => array(1, null), // require one to many Columns );

or: array( self::NT_PROPERTY => array(null, 1), // require none to 1 properties );

Return Value

array

AbstractNode setChild(AbstractNode $node)

Remove any previous children and add given node via. addChild.

Parameters

AbstractNode $node

Return Value

AbstractNode

See also

removeChildrenOfType
addChild

AbstractNode addChild(AbstractNode $node)

Add a child to this node.

Exception will be thrown if child node type is not described in the cardinality map, or if the maxiumum permitted number of nodes would be exceeded by adding the given child node.

The given node will be returned EXCEPT when the current node is a leaf node, in which case we return the parent.

Parameters

AbstractNode $node

Return Value

AbstractNode

Exceptions

OutOfBoundsException

AbstractNode getNext()

Return the next object in the fluid interface chain. Leaf nodes always return the parent, deafult behavior is to return /this/ class.

Return Value

AbstractNode

AbstractNode[] getChildren()

Return all child nodes.

Note that this will returned a flattened version of the classes type => children map.

Return Value

AbstractNode[]

AbstractNode[] getChildrenOfType(string $type)

Return children of specified type.

Parameters

string $type The type name.

Return Value

AbstractNode[]

removeChildrenOfType($type)

Parameters

$type

AbstractNode getChild()

Return child of node, there must be exactly one child of any type.

Return Value

AbstractNode

Exceptions

OutOfBoundsException if there are more than one or none

AbstractNode getChildOfType(string $type)

Return child of specified type.

Note: This does not take inheritance into account.

Parameters

string $type The name of the type.

Return Value

AbstractNode

Exceptions

OutOfBoundsException if there are more than one or none

validate()

Validate the current node.

Validation is performed both when the query is being built and when the dev explicitly calls "end()".

This method simply checks the minimum boundries are satisfied, the addChild() method already validates maximum boundries and types.

AbstractNode end()

Validates this node and returns its parent.

This should be used if the developer wants to define the entire Query in a fluid manner.

Return Value

AbstractNode

__call(string $methodName, array $args)

Catch any undefined method calls and tell the developer what methods can be called.

Parameters

string $methodName The requested nonexistent method.
array $args The arguments that where used.

Exceptions

BadMethodCallException if an unknown method is called.

ensureNoArguments($method, $void)

Parameters

$method
$void

getFactoryMethods()

ConstraintAndx andX()

And composite constraint::.

$qb->where() ->andX() ->fieldIsset('f.foo') ->gt()->field('f.max')->literal(40)->end() ->end() ->end();

The andX node allows you to add 1, 2 or many operand nodes. When one operand is added the "and" is removed, when more than one is added the "and" operands are nested::

// when adding only a single operand, $qb->where()->andX()->eq()->field('f.foo')->literal('bar'); // is equivilent to: $qb->where()->eq()->field('f.foo')->literal('bar');

// when adding more than one, $qb->where() ->andX() ->fieldIsset('f.foo') ->gt()->field('f.max')->literal(40)->end() ->eq()->field('f.zar')->literal('bar')->end() ->end() ->end();

// is equivilent to: $qb->where() ->andX() ->fieldIsset('f.foo') ->andX() ->gt()->field('f.max')->literal(40)->end() ->eq()->field('f.zar')->litreal('bar')->end() ->end() ->end() ->end();

Return Value

ConstraintAndx

ConstraintOrx orX()

Or composite constraint::.

$qb->where() ->orX() ->fieldIsset('sel_1.prop_1') ->fieldIsset('sel_1.prop_2') ->end() ->end();

As with "andX", "orX" allows one to many operands.

Return Value

ConstraintOrx

ConstraintFactory fieldIsset(string $field)

Field existance constraint::.

$qb->where()->fieldIsset('sel_1.prop_1')->end();

Parameters

string $field
  • Field to check

Return Value

ConstraintFactory

ConstraintFactory fullTextSearch(string $field, string $fullTextSearchExpression)

Full text search constraint::.

$qb->where()->fullTextSearch('sel_1.prop_1', 'search_expression')->end();

Parameters

string $field
  • Name of field to check, including alias name.
string $fullTextSearchExpression
  • Search expression.

Return Value

ConstraintFactory

ConstraintFactory same(string $path, string $alias)

Same document constraint::.

$qb->where()->same('/path/to/doc', 'sel_1')->end();

Relates to PHPCR QOM SameNodeInterface.

Parameters

string $path
  • Path to reference document.
string $alias
  • Name of alias to use.

Return Value

ConstraintFactory

ConstraintFactory descendant(string $ancestorPath, string $alias)

Descendant document constraint::.

$qb->where()->descendant('/ancestor/path', 'sel_1')->end();

Relates to PHPCR QOM DescendantNodeInterface

Parameters

string $ancestorPath
  • Select descendants of this path.
string $alias
  • Name of alias to use.

Return Value

ConstraintFactory

ConstraintFactory child(string $parentPath, string $alias)

Select children of the aliased document at the given path::.

$qb->where()->child('/parent/path', 'sel_1')->end();

Relates to PHPCR QOM ChildNodeInterface.

Parameters

string $parentPath
  • Select children of this path.
string $alias
  • Name of alias to use

Return Value

ConstraintFactory

ConstraintFactory not()

Inverts the truth of the given appended constraint.

Return Value

ConstraintFactory

ConstraintComparison eq()

Equality comparison constraint::.

$qb->where() ->eq() ->field('sel_1.foobar') ->literal('var_1') ->end();

Return Value

ConstraintComparison

ConstraintComparison neq()

Inequality comparison constraint::.

$qb->where() ->neq() ->field('sel_1.foobar') ->literal('var_1') ->end();

Return Value

ConstraintComparison

ConstraintComparison lt()

Less than comparison constraint::.

$qb->where() ->lt() ->field('sel_1.foobar') ->literal(5) ->end();

Return Value

ConstraintComparison

ConstraintComparison lte()

Less than or equal to comparison constraint::.

$qb->where() ->lte() ->field('sel_1.foobar') ->literal(5) ->end();

Return Value

ConstraintComparison

ConstraintComparison gt()

Greater than comparison constraint::.

$qb->where() ->gt() ->field('sel_1.foobar') ->literal(5) ->end();

Return Value

ConstraintComparison

ConstraintComparison gte()

Greater than or equal to comparison constraint::.

$qb->where() ->gte() ->field('sel_1.foobar') ->literal(5) ->end();

Return Value

ConstraintComparison

ConstraintComparison like()

Like comparison constraint.

Use "%" as wildcards::

$qb->where() ->like() ->field('sel_1.foobar') ->literal('foo%') ->end();

The above example will match "foo" and "foobar" but not "barfoo".

Return Value

ConstraintComparison