CodeIgniter v4.7 API

ConditionalTrait

Table of Contents

Methods

when()  : self
Only runs the query when $condition evaluates to true
whenNot()  : self
Only runs the query when $condition evaluates to false

Methods

when()

Only runs the query when $condition evaluates to true

public when(TWhen $condition, callable(self, TWhen): mixed $callback[, callable(self): mixed|null $defaultCallback = null ]) : self
Parameters
$condition : TWhen
$callback : callable(self, TWhen): mixed
$defaultCallback : callable(self): mixed|null = null
Tags
template
Return values
self

whenNot()

Only runs the query when $condition evaluates to false

public whenNot(TWhenNot $condition, callable(self, TWhenNot): mixed $callback[, callable(self): mixed|null $defaultCallback = null ]) : self
Parameters
$condition : TWhenNot
$callback : callable(self, TWhenNot): mixed
$defaultCallback : callable(self): mixed|null = null
Tags
template
Return values
self
On this page

Search results