public function multiInsertOrUpdate(
        string $table,
        array $rows,
        int $updateIgnoreCount = 1,
        ?array $excludeEmptyColumns = null
    ) {
        if (empty($rows)) {
            return 0;
        }

        if (null !== $excludeEmptyColumns) {
            $rows = SqlPreparator::setNullValues($rows, $excludeEmptyColumns);
        }

        if ($updateIgnoreCount) {
            $ignoreForUpdate = array_slice(SqlPreparator::extractColumnsFromRows($rows), 0, $updateIgnoreCount);
        } else {
            $ignoreForUpdate = [];
        }

        [$sql, $params] = array_values(SqlPreparator::prepareMultiInsertOrUpdate($table, $rows, $ignoreForUpdate));

        $affected = $this->conn->executeUpdate($sql, $params);

        return $affected;
    }
public function multiInsertOrUpdate(
        string $table,
        array $rows,
        int $updateIgnoreCount = 1,
        ?array $excludeEmptyColumns = null
    ) {
        if (empty($rows)) {
            return 0;
        }

        if (null !== $excludeEmptyColumns) {
            $rows = SqlPreparator::setNullValues($rows, $excludeEmptyColumns);
        }

        if ($updateIgnoreCount) {
            $ignoreForUpdate = array_slice(SqlPreparator::extractColumnsFromRows($rows), 0, $updateIgnoreCount);
        } else {
            $ignoreForUpdate = [];
        }

        [$sql, $params] = array_values(SqlPreparator::prepareMultiInsertOrUpdate($table, $rows, $ignoreForUpdate));

        $affected = $this->conn->executeUpdate($sql, $params);

        return $affected;
    }
public function multiInsertOrUpdate ( string $ table , array $ rows , int $ updateIgnoreCount = 1 , ? array $ excludeEmptyColumns = null ) { if ( empty ( $ rows ) ) { return 0 ; } if ( null !== $ excludeEmptyColumns ) { $ rows = SqlPreparator :: setNullValues ( $ rows , $ excludeEmptyColumns ) ; } if ( $ updateIgnoreCount ) { $ ignoreForUpdate = array_slice ( SqlPreparator :: extractColumnsFromRows ( $ rows ) , 0 , $ updateIgnoreCount ) ; } else { $ ignoreForUpdate = [ ] ; } [ $ sql , $ params ] = array_values ( SqlPreparator :: prepareMultiInsertOrUpdate ( $ table , $ rows , $ ignoreForUpdate ) ) ; $ affected = $ this -> conn -> executeUpdate ( $ sql , $ params ) ; return $ affected ; }
executes "INSERT...ON DUPLICATE KEY UPDATE" sql statement by multi array of values
to be used for bulk inserts

@param string     $table               table name
@param array      $rows                2-dimensional array of values to insert
@param int        $updateIgnoreCount   how many fields from beginning of array should be ignored on update
(i.e. indexes) default: 1 (the ID)
@param array|null $excludeEmptyColumns array of columns that can contain zero-equal values,
set to null if you want to disable auto-null entirely [default: null]

@return int|array number of affected rows or ['inserted' => int, 'updated' => int] if $returnAsArray = true

@throws DBALManagerException
executes INSERT ... ON DUPLICATE KEY UPDATE sql statement by multi array of values to be used for bulk inserts