Oihana PHP

predicates.php

Table of Contents

Functions

predicates()  : string|null
Generate a complex logical expression with multiple predicates.

Functions

predicates()

Generate a complex logical expression with multiple predicates.

predicates(array<int, string>|null $conditions, string $logicalOperator[, bool $useParentheses = false ][, bool $spacify = true ]) : string|null
Parameters
$conditions : array<int, string>|null

List of predicate expressions.

$logicalOperator : string

The logical operator to join predicates (e.g., 'AND', 'OR').

$useParentheses : bool = false

Whether to wrap the result in parentheses.

$spacify : bool = true

Whether to pad the operator with spaces (e.g. AND vs AND). Default true.

Tags
example
$predicates = [
    $this->predicate('a', '==', 1),
    $this->predicate('b', '>', 5)
];
$this->predicates( $predicates , 'AND' , true ) ; // '(a == 1 AND b > 5)'
since
1.0.0
author

Marc Alcaraz

Return values
string|null

The combined expression or null if empty.

On this page

Search results