yii\sphinx\QueryBuilder::composeColumnValue PHP Method

composeColumnValue() protected method

Composes column value for SQL, taking in account the column type.
protected composeColumnValue ( IndexSchema[] $indexes, string $columnName, mixed $value, array &$params ) : string
$indexes IndexSchema[] list of indexes, which affected by query
$columnName string name of the column
$value mixed raw column value
$params array the binding parameters to be populated
return string SQL expression, which represents column value
    protected function composeColumnValue($indexes, $columnName, $value, &$params)
    {
        if ($value === null) {
            return 'NULL';
        } elseif ($value instanceof Expression) {
            $params = array_merge($params, $value->params);
            return $value->expression;
        }
        foreach ($indexes as $index) {
            $columnSchema = $index->getColumn($columnName);
            if ($columnSchema !== null) {
                break;
            }
        }
        if (is_array($value)) {
            // MVA :
            $lineParts = [];
            foreach ($value as $subValue) {
                if ($subValue instanceof Expression) {
                    $params = array_merge($params, $subValue->params);
                    $lineParts[] = $subValue->expression;
                } else {
                    $phName = self::PARAM_PREFIX . count($params);
                    $lineParts[] = $phName;
                    $params[$phName] = isset($columnSchema) ? $columnSchema->dbTypecast($subValue) : $subValue;
                }
            }
            return '(' . implode(',', $lineParts) . ')';
        } else {
            $phName = self::PARAM_PREFIX . count($params);
            $params[$phName] = isset($columnSchema) ? $columnSchema->dbTypecast($value) : $value;
            return $phName;
        }
    }