Tribe__Repository::where_or( array $callbacks )
Builds a fenced group of WHERE clauses that will be used with OR logic.
Contents
Mind that this is a lower level implementation of WHERE logic that requires each callback method to add, at least, one WHERE clause using the repository own where_clause method.
See also
Parameters
- $callbacks
-
(array) (Required) One or more WHERE callbacks that will be called this repository. The callbacks have the shape [ <method>, <...args>]
Return
($this)
Source
File: src/Tribe/Repository.php
public function where_or( $callbacks ) {
$callbacks = func_get_args();
$buffered = $this->filter_query->get_buffered_where_clauses( true );
$this->filter_query->buffer_where_clauses( true );
$buffered_count = count( $buffered );
foreach ( $callbacks as $c ) {
call_user_func_array( array( $this, $c[0] ), array_slice( $c, 1 ) );
if ( $buffered_count === count( $this->filter_query->get_buffered_where_clauses() ) ) {
throw Tribe__Repository__Usage_Error::because_where_or_should_only_be_used_with_methods_that_add_where_clauses( $c, $this );
}
$buffered_count ++;
}
$buffered = $this->filter_query->get_buffered_where_clauses( true );
$fenced = sprintf( '( %s )', implode( ' OR ', $buffered ) );
$this->where_clause( $fenced );
return $this;
}