whereFloat()

The whereFloat() method provides type-safe filtering for floating-point and decimal columns. It automatically validates the input and prevents misuse of string values or injection attempts.

This method internally uses secureWhere() with strict type checking for float-compatible columns.

Basic usage

Use whereFloat() like the regular where() method, but exclusively for float-compatible columns:

$db->whereFloat('price', 19.99);
$db->orWhereFloat('price', 0.0, '>');

$db->get('products');

The third parameter (operator) is optional and defaults to =. You may also use comparison operators like !=, >, >=, <, etc.

Input validation

Only valid float values (including float, int, and numeric strings like "123.45") are allowed. Invalid input (e.g. arrays, SQL snippets, or unsafe strings) will throw an exception.

❌ Invalid: $db->whereFloat('price', '1 OR 1=1')
✅ Valid: $db->whereFloat('price', '9.99') (numeric string)

Use with orWhereFloat()

All type-safe where* methods are also available as orWhere* variants for logical OR chaining:

$db->whereFloat('price', 0.0, '>');
$db->orWhereFloat('discount', 5.0, '>=');

$db->get('offers');

See also