Doc error ?
Doc error ?
Lapointe
Posts: 430Questions: 81Answers: 4
in Bug reports
( 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
This discussion has been closed.
Answers
Can you post the link to that doc, please, and also explain where the error is.
Colin
Hi @colin
Sorry
https://editor.datatables.net/docs/1.9.5/php/class-DataTables.Database.Query.html#_where
Doc say : The following will produce
'WHERE name='allan' AND ( location='Scotland' OR location='Canada' ):
but I think result will be
"WHERE name='allan' AND ( location='Scotland' AND location='Canada' ):"
Thanks! Fixed here.
Allan