Complete reference for all helper functions.
Raw SQL value.
Db::raw('NOW()');Escape string.
Db::escape($userInput);Configuration value.
Db::config('FOREIGN_KEY_CHECKS', 0);CONCAT function.
Db::concat('first_name', ' ', 'last_name');UPPER function.
Db::upper('email');LOWER function.
Db::lower('email');TRIM function.
Db::trim('name');SUBSTRING function.
Db::substring('name', 1, 10);LENGTH function.
Db::length('name');Left substring.
Db::left('name', 2);Right substring.
Db::right('name', 2);Substring position (1-based).
Db::position(Db::raw("'@'"), 'email');Repeat string.
Db::repeat(Db::raw("'-'"), 5);Reverse string.
Db::reverse('name');Left pad.
Db::padLeft('name', 8, ' ');Right pad.
Db::padRight('name', 8, '.');Increment value.
Db::inc('views');
Db::inc('views', 5);Decrement value.
Db::dec('stock');Absolute value.
Db::abs('price');Round value.
Db::round('price', 2);Ceiling (round up).
Db::ceil('price');Floor (round down).
Db::floor('price');Exponentiation.
Db::power('score', 2);Square root.
Db::sqrt('distance');Exponential function.
Db::exp(1);Natural logarithm.
Db::ln('value');Logarithm (base 10 by default).
Db::log('value');
Db::log('value', 2);Truncate without rounding.
Db::trunc('price', 1);Current timestamp.
Db::now();Current date.
Db::curDate();Current time.
Db::curTime();Add interval.
Db::addInterval('created_at', '1', 'DAY');Subtract interval.
Db::subInterval('created_at', '1', 'MONTH');IS NULL check.
Db::isNull('deleted_at');IS NOT NULL check.
Db::isNotNull('email');IFNULL function.
Db::ifNull('nickname', 'Anonymous');NULLIF function.
Db::nullIf('nickname', '');LIKE pattern.
Db::like('name', '%john%');BETWEEN values.
Db::between('age', 18, 65);IN values.
Db::in('status', ['active', 'pending']);NOT IN values.
Db::notIn('status', ['deleted', 'banned']);Extract JSON value.
Db::jsonExtract('data', '$.name');Check JSON contains.
Db::jsonContains('tags', 'php');Set JSON value.
Db::jsonSet('data', '$.status', 'active');COUNT aggregate.
Db::count();
Db::count('id');SUM aggregate.
Db::sum('price');AVG aggregate.
Db::avg('price');MIN aggregate.
Db::min('price');MAX aggregate.
Db::max('price');Db::groupConcat(string|RawValue $column, string $separator = ',', bool $distinct = false): CallableInterface
Concatenate values per group (dialect-specific: GROUP_CONCAT/STRING_AGG).
Db::groupConcat('name', ', ', true);- API Reference - Complete API
- Query Builder Methods - Query builder methods
- PdoDb Methods - PdoDb methods