CodeIgniter v4.6 API

ConditionalTrait

Table of Contents

Methods

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

Methods

when()

Only runs the query when $condition evaluates to true

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

whenNot()

Only runs the query when $condition evaluates to false

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

        
On this page

Search results