src/InsertOnDuplicateKey.php
protected static function buildInsertOnDuplicateSql(array $data, array $updateColumns = null)
    {
        $first = static::getFirstRow($data);

        $sql  = 'INSERT INTO `' . static::getTablePrefix() . static::getTableName() . '`(' . static::getColumnList($first) . ') VALUES' . PHP_EOL;
        $sql .=  static::buildQuestionMarks($data) . PHP_EOL;
        $sql .= 'ON DUPLICATE KEY UPDATE ';

        if (empty($updateColumns)) {
            $sql .= static::buildValuesList(array_keys($first));
        } else {
            $sql .= static::buildValuesList($updateColumns);
        }

        return $sql;
    }
protected static function buildInsertOnDuplicateSql(array $data, array $updateColumns = null)
    {
        $first = static::getFirstRow($data);

        $sql  = 'INSERT INTO `' . static::getTablePrefix() . static::getTableName() . '`(' . static::getColumnList($first) . ') VALUES' . PHP_EOL;
        $sql .=  static::buildQuestionMarks($data) . PHP_EOL;
        $sql .= 'ON DUPLICATE KEY UPDATE ';

        if (empty($updateColumns)) {
            $sql .= static::buildValuesList(array_keys($first));
        } else {
            $sql .= static::buildValuesList($updateColumns);
        }

        return $sql;
    }
protected static function buildInsertOnDuplicateSql ( array $ data , array $ updateColumns = null ) { $ first = static :: getFirstRow ( $ data ) ; $ sql = 'INSERT INTO `' . static :: getTablePrefix ( ) . static :: getTableName ( ) . '`(' . static :: getColumnList ( $ first ) . ') VALUES' . PHP_EOL ; $ sql .= static :: buildQuestionMarks ( $ data ) . PHP_EOL ; $ sql .= 'ON DUPLICATE KEY UPDATE ' ; if ( empty ( $ updateColumns ) ) { $ sql .= static :: buildValuesList ( array_keys ( $ first ) ) ; } else { $ sql .= static :: buildValuesList ( $ updateColumns ) ; } return $ sql ; }
Build the INSERT ON DUPLICATE KEY sql statement.

@param array $data
@param array $updateColumns

@return string
Build the INSERT ON DUPLICATE KEY sql statement .