public function callSnippets($index, $source, $match, $options, &$params)
    {
        if (is_array($source)) {
            $dataSqlParts = [];
            foreach ($source as $sourceRow) {
                $phName = self::PARAM_PREFIX . count($params);
                $params[$phName] = (string)$sourceRow;
                $dataSqlParts[] = $phName;
            }
            $dataSql = '(' . implode(',', $dataSqlParts) . ')';
        } else {
            $phName = self::PARAM_PREFIX . count($params);
            $params[$phName] = $source;
            $dataSql = $phName;
        }
        $indexParamName = self::PARAM_PREFIX . count($params);
        $params[$indexParamName] = $index;

        $matchSql = $this->buildMatch($match, $params);

        if (!empty($options)) {
            $optionParts = [];
            foreach ($options as $name => $value) {
                if ($value instanceof Expression) {
                    $actualValue = $value->expression;
                } else {
                    $actualValue = self::PARAM_PREFIX . count($params);
                    $params[$actualValue] = $value;
                }
                $optionParts[] = $actualValue . ' AS ' . $name;
            }
            $optionSql = ', ' . implode(', ', $optionParts);
        } else {
            $optionSql = '';
        }

        return 'CALL SNIPPETS(' . $dataSql. ', ' . $indexParamName . ', ' . $matchSql . $optionSql. ')';
    }
public function callSnippets($index, $source, $match, $options, &$params)
    {
        if (is_array($source)) {
            $dataSqlParts = [];
            foreach ($source as $sourceRow) {
                $phName = self::PARAM_PREFIX . count($params);
                $params[$phName] = (string)$sourceRow;
                $dataSqlParts[] = $phName;
            }
            $dataSql = '(' . implode(',', $dataSqlParts) . ')';
        } else {
            $phName = self::PARAM_PREFIX . count($params);
            $params[$phName] = $source;
            $dataSql = $phName;
        }
        $indexParamName = self::PARAM_PREFIX . count($params);
        $params[$indexParamName] = $index;

        $matchSql = $this->buildMatch($match, $params);

        if (!empty($options)) {
            $optionParts = [];
            foreach ($options as $name => $value) {
                if ($value instanceof Expression) {
                    $actualValue = $value->expression;
                } else {
                    $actualValue = self::PARAM_PREFIX . count($params);
                    $params[$actualValue] = $value;
                }
                $optionParts[] = $actualValue . ' AS ' . $name;
            }
            $optionSql = ', ' . implode(', ', $optionParts);
        } else {
            $optionSql = '';
        }

        return 'CALL SNIPPETS(' . $dataSql. ', ' . $indexParamName . ', ' . $matchSql . $optionSql. ')';
    }
public function callSnippets ( $ index , $ source , $ match , $ options , & $ params ) { if ( is_array ( $ source ) ) { $ dataSqlParts = [ ] ; foreach ( $ source as $ sourceRow ) { $ phName = self :: PARAM_PREFIX . count ( $ params ) ; $ params [ $ phName ] = ( string ) $ sourceRow ; $ dataSqlParts [ ] = $ phName ; } $ dataSql = '(' . implode ( ',' , $ dataSqlParts ) . ')' ; } else { $ phName = self :: PARAM_PREFIX . count ( $ params ) ; $ params [ $ phName ] = $ source ; $ dataSql = $ phName ; } $ indexParamName = self :: PARAM_PREFIX . count ( $ params ) ; $ params [ $ indexParamName ] = $ index ; $ matchSql = $ this -> buildMatch ( $ match , $ params ) ; if ( ! empty ( $ options ) ) { $ optionParts = [ ] ; foreach ( $ options as $ name => $ value ) { if ( $ value instanceof Expression ) { $ actualValue = $ value -> expression ; } else { $ actualValue = self :: PARAM_PREFIX . count ( $ params ) ; $ params [ $ actualValue ] = $ value ; } $ optionParts [ ] = $ actualValue . ' AS ' . $ name ; } $ optionSql = ', ' . implode ( ', ' , $ optionParts ) ; } else { $ optionSql = '' ; } return 'CALL SNIPPETS(' . $ dataSql . ', ' . $ indexParamName . ', ' . $ matchSql . $ optionSql . ')' ; }
Builds a SQL statement for call snippet from provided data and query, using specified index settings.
@param string $index name of the index, from which to take the text processing settings.
@param string|array $source is the source data to extract a snippet from.
It could be either a single string or array of strings.
@param string $match the full-text query to build snippets for.
@param array $options list of options in format: optionName => optionValue
@param array $params the binding parameters that will be modified by this method
so that they can be bound to the Sphinx command later.
@return string the SQL statement for call snippets.
Builds a SQL statement for call snippet from provided data and query using specified index settings .