You write the code inside Model. Model contains classes, validations and operations. Controller interacts with the View-Model (in this case calls to your Database operation).
For example, you can see
this link[
^].
I wrote a wrong comment :(
Thanks to @CHill60 and @Wes Aday for their comments.