Doc error ?

Doc error ?

LapointeLapointe Posts: 430Questions: 81Answers: 4

( location='Scotland' OR location='Canada' ) or ( location='Scotland' AND location='Canada' )

public DataTables\Database\Query    
#where( string|string[]|callable $key, string|string[] $value = null, string $op = "=", boolean $bind = true  )
Where query - **multiple conditions are bound as ANDs.**

Can be used in two different ways, as where( field, value ) or as an array of conditions to use: where( array('fieldName', ...), array('value', ...) );

Parameters
$key
Single field name, or an array of field names. If given as a function (i.e. a closure), the function is called, passing the query itself in as the only parameter, so the function can add extra conditions with parentheses around the additional parameters.

$value
Single field value, or an array of values. Can be null to search for IS NULL or IS NOT NULL (depending on the value of $op which should be = or !=.

$op
Condition operator: <, >, = etc
$bind
Escape the value (true, default) or not (false).
Returns
DataTables\Database\Query
Example
The following will produce 'WHERE name='allan' AND ( location='Scotland' **OR** location='Canada' ):



$query
    ->where( 'name', 'allan' )
    ->where( function ($q) {
      $q->where( 'location', 'Scotland' );
      $q->where( 'location', 'Canada' );
    } );

This question has an accepted answers - jump to answer

Answers

This discussion has been closed.