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

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

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

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

        return $sql;
    }
protected function buildUpsert ( $ tablename , array $ row , $ quotevals = true , $ options = [ ] ) { // Build the initial insert statement first. unset ( $ options [ Db :: OPTION_UPSERT ] ) ; $ sql = $ this -> buildInsert ( $ tablename , $ row , $ quotevals , $ options ) ; // Add the duplicate key stuff. $ updates = [ ] ; foreach ( $ row as $ key => $ value ) { $ updates [ ] = $ this -> backtick ( $ key ) . ' = values(' . $ this -> backtick ( $ 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 $tablename The name of the table to update.
@param array $row The row to insert or update.
@param bool $quotevals Whether or not to quote the values in the row.
@param array $options An array of additional query options.
@return string Returns the upsert statement as a string.
Build an upsert statement .