-
Notifications
You must be signed in to change notification settings - Fork 0
normalizeWhere
Processes and converts key-value pairs, indexed arrays, and fully-keyed associative arrays into a uniform format to simplify downstream SQL generation. Used within the andWhere and orWhere methods.
normalizeWhere(array $array = []): array
array (array) : The multi-dimensional array containing supported input formats.
Each element must follow one of the three supported structures:
1️⃣ Key-Value Pair: An associative array where the key is the
columnand the value is thevalue. Uses the default=operator. (ex.['user' => 'name'])2️⃣ Indexed Array: A numerically indexed array representing
column,valueandop(in that order). The 3rd value is optional and defaults to=. (ex.['qty', 10, '>']or['user', 'name'])3️⃣ Full Associative Array: A formal array using explicit
column,value, andopkeys. (ex.['column' => 'user', 'value' => 'name', 'op' => '<>'])
(array) : Returns the uniform array.
$db->normalizeWhere(['id' => 12])
// Result: ['column' => 'id', 'value' => 12, 'op' => '=']
$db->normalizeWhere(['qty', 10, '>'])
// Result: ['column' => 'qty', 'value' => 10, 'op' => '>']
- Logs a notice if no array is present.
where | andWhere | orWhere | whereGroup | whereStr