protected function buildUpsert($table, array $row, $options = []) {
        // Build the initial insert statement first.
        unset($options[Db::OPTION_UPSERT]);
        $sql = $this->buildInsert($table, $row, $options);

        // Add the duplicate key stuff.
        $updates = [];
        foreach ($row as $key => $value) {
            $updates[] = $this->escape($key).' = values('.$this->escape($key).')';
        }
        $sql .= "\non duplicate key update ".implode(', ', $updates);

        return $sql;
    }
protected function buildUpsert($table, array $row, $options = []) {
        // Build the initial insert statement first.
        unset($options[Db::OPTION_UPSERT]);
        $sql = $this->buildInsert($table, $row, $options);

        // Add the duplicate key stuff.
        $updates = [];
        foreach ($row as $key => $value) {
            $updates[] = $this->escape($key).' = values('.$this->escape($key).')';
        }
        $sql .= "\non duplicate key update ".implode(', ', $updates);

        return $sql;
    }
protected function buildUpsert ( $ table , array $ row , $ options = [ ] ) { // Build the initial insert statement first. unset ( $ options [ Db :: OPTION_UPSERT ] ) ; $ sql = $ this -> buildInsert ( $ table , $ row , $ options ) ; // Add the duplicate key stuff. $ updates = [ ] ; foreach ( $ row as $ key => $ value ) { $ updates [ ] = $ this -> escape ( $ key ) . ' = values(' . $ this -> escape ( $ key ) . ')' ; } $ sql .= "\non duplicate key update " . implode ( ', ' , $ updates ) ; return $ sql ; }
Build an upsert statement.

An upsert statement is an insert on duplicate key statement in MySQL.

@param string|Identifier $table The name of the table to update.
@param array $row The row to insert or update.
@param array $options An array of additional query options.
@return string Returns the upsert statement as a string.
Build an upsert statement .