Newbie questions about models

do u have to have a model for every table in your database? if not how do use say 5 different tables within one model? for example, say i have a model called Baseball.php and i want to use 5 different tables in my model. so say i have thses tables: baseballteams baseballcities baseballmascots baseballleagues baseball_positions

how can i use the one model to run find on each table?

thanks in advance for the help



5.3k

You should have one model for each table. The model IS the table, so to speak.



1.6k

A model is a entity.

Because a baseballteam is not the same as a baseballmascot you don't persist them in the same table. So why would you use a single entity to store two different entities? In Phalcon a model is use to store the data it retrieved from the database in a logical way. Unlike some frameworks which use a model as database access layer and query other tables from a single table.

Thanks for the answers so say I have a database with 100 different tables. I will need a Model for each one?

Also, is there a db adpater for MicroSoft SQL databases???