yii\sphinx\QueryBuilder::generateBatchInsertReplace PHP Method

generateBatchInsertReplace() protected method

Generates a batch INSERT/REPLACE SQL statement.
protected generateBatchInsertReplace ( string $statement, string $index, array $columns, array $rows, array &$params ) : string
$statement string statement ot be generated.
$index string the affected index name.
$columns array the column data (name => value).
$rows array the rows to be batch inserted into the index
$params array the binding parameters that will be generated by this method.
return string generated SQL
    protected function generateBatchInsertReplace($statement, $index, $columns, $rows, &$params)
    {
        if (($indexSchema = $this->db->getIndexSchema($index)) !== null) {
            $indexSchemas = [$indexSchema];
        } else {
            $indexSchemas = [];
        }
        $notNullColumns = [];
        $values = [];
        foreach ($rows as $row) {
            $vs = [];
            foreach ($row as $i => $value) {
                if ($value === null) {
                    continue;
                } elseif (!in_array($columns[$i], $notNullColumns)) {
                    $notNullColumns[] = $columns[$i];
                }
                $vs[] = $this->composeColumnValue($indexSchemas, $columns[$i], $value, $params);
            }
            $values[] = '(' . implode(', ', $vs) . ')';
        }
        foreach ($notNullColumns as $i => $name) {
            $notNullColumns[$i] = $this->db->quoteColumnName($name);
        }
        return $statement . ' INTO ' . $this->db->quoteIndexName($index) . ' (' . implode(', ', $notNullColumns) . ') VALUES ' . implode(', ', $values);
    }