Class JTable
is created to work strictly on database object. Table object should create,modify,delete,check data in database. It can be used in many models, helpers, modules. Single model some times have to use multiple tables and it can happen in many models. If you use JTable
you don't have to rewrite SQL in every model just to retrieve or modify a single table record. Not to mention that changes in a JTable
work in every place where table was used.
Class JModel
is created to work on data. Usually it works on database data but also files, images or simply calculations. Models don't require a JTable
, you can easly write a working JModel
without it. But when you have to create for example a user account on a complex portal it is possible user data will consist not only of a single table but also example data or records in other tables. Using JTable
will allow you to save time on writing CRUD methods and make sure that in every place a single table is used SQL will always be up-to-date.
Having those two separated allows developer to create various extensions that are not tied strictly to database. For example gallery that in model will not only work on database object but also images. Developer does write image processing code and leaves SQL for creating and updating database to JTable
.
It can be a bit confusing at the beginning but after few extension you'll see that it is actually helpful. The bigger the extension the more time JTable
+JModel
will save for developer. The only problem is that it isn't properly explained in documentation.
Here are some useful links
JTable
class?