method getQueryValues documentation in bbn\Db\Languages\Sql
function(array $cfg)
{
$res = [];
if (!empty($cfg['values'])) {
// Only for the insert / update part (at the start of the query), before the where (but not before the join in insert / update beware!)
$num_types = in_array($cfg['kind'], ['INSERT', 'UPDATE']) && !empty($cfg['values_types']) ? count($cfg['values_types']) : 0;
foreach ($cfg['values'] as $i => $v) {
if (!isset($cfg['values_desc'][$i])) {
X::log([$i, $cfg['values_desc'], $v], 'no_desc_in_sql');
}
if ($num_types && ($i < $num_types) && ($cfg['values_desc'][$i]['type'] === 'exp')) {
continue;
}
// Transforming the values if needed
if (($cfg['values_desc'][$i]['type'] === 'binary')
&& ($cfg['values_desc'][$i]['maxlength'] === 16)
&& Str::isUid($v)
) {
$res[] = hex2bin($v);
}
elseif (\is_string($v) && (( ($cfg['values_desc'][$i]['type'] === 'date')
&& (\strlen($v) < 10)) || ( ($cfg['values_desc'][$i]['type'] === 'time')
&& (\strlen($v) < 8)) || ( ($cfg['values_desc'][$i]['type'] === 'datetime')
&& (\strlen($v) < 19)) )
) {
$res[] = $v.'%';
}
elseif (!empty($cfg['values_desc'][$i]['operator'])) {
switch ($cfg['values_desc'][$i]['operator']){
case 'contains':
case 'doesnotcontain':
$res[] = '%'.$v.'%';
break;
case 'startswith':
$res[] = $v.'%';
break;
case 'endswith':
$res[] = '%'.$v;
break;
default:
$res[] = $v;
}
}
else{
$res[] = $v;
}
}
}
return $res;
}
BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way
This website uses cookies to ensure you get the best experience on our website.
© 2011-2025
BBN Solutions