How to download music from my iPhone to iTunes?

I just got a new macbook air and all of my music from my previous computer is on my iPhone. I asked the people at the Apple store how to do it but they said that since I have music on my phone that I didn't purchase, the songs will get deleted when i sync my phone to the computer. I don't want to lose all of my music so how can I transfer all of my phones music to my computer without losing all of it?

Try reading the answers given to the last 300 people to have already asked this question.

An iPhone can be synced with only one iTunes account at a time.once you switched to a new iTunes account or a new computer. You have to authorize your iPhone to it at first, then you can upload music and video from iPhone to computer. You can use this tool that helped me before
http://www.001-software.com/itransfer/mac.html

When you want to transfer music that were not purchased from itunes, you will need another 3-rd party software to do that. Here's an article explaining how to transfer music from iphone to itunes on mac: http://www.m-reviews.com/How-to-transfer-music-from-iPhone-to-iTunes-on-Mac.html
You can check it and see if it helps.

I don't have idea. If someone has any guides would like to know of these as well.