This commit is contained in:
2021-03-04 15:55:17 +08:00
parent 66c7d39a5a
commit e8e5641f41
+23 -7
View File
@@ -123,13 +123,8 @@ trait Builder
if (empty($where)) return '';
if (is_string($where)) return $where;
foreach ($where as $key => $value) {
if (is_string($key)) {
$_value = sprintf('%s=\'%s\'', $key, $value);
} else if (is_string($value)) {
$_value = $value;
} else {
$_value = $this->_arrayMap($value, $_tmp);
}
$_value = $this->resolveCondition($key, $value, $_tmp);
if (empty($_value)) continue;
$_tmp[] = $_value;
}
@@ -140,6 +135,27 @@ trait Builder
}
/**
* @param $field
* @param $condition
* @param $_tmp
* @return string
* @throws NotFindClassException
* @throws ReflectionException
*/
private function resolveCondition($field, $condition, $_tmp): string
{
if (is_string($field)) {
$_value = sprintf('%s=\'%s\'', $field, $condition);
} else if (is_string($condition)) {
$_value = $condition;
} else {
$_value = $this->_arrayMap($condition, $_tmp);
}
return $_value;
}
/**
* @param $condition
* @param $array