Working with my own SQL query

Hi, I found this docs

After reading this docs I want to try it.but I am confuse where should I put those sql statements and the connections statements of my db. Is it in my created model or I need to create a new php file under models folder. then put those sql statements ?

please enlighten my mind.

Thank you.

What exactly confuses U ?