Components are used to provide additional functionality to the framework when the use of another type would not be appropriate. Controllers are for business logic, Models are for data handling, and Templates are for markup and display logic.
A MySQL Component creates an abstraction layer for connecting to, querying, managing results from, and preparing data for a MySQL database. It's scope is beyond that of a Controller, and a template certainly won't do! Why not use a model? Didn't we say that models are for handling data? Yes, models are for handling data, but not for fetching data from a database. All the model really cares is that it receives the data it requires, whether it be formatted in XML, array, CSV, or other. It is completely uninterested in how the data is collected. This is where the Component comes into play.
© Copyright 2010 negative11.com