At what point do you seperate things into different models? |
06-20-2016, 05:49 PM
(This post was last modified: 06-20-2016, 05:51 PM by John_Betong. Edit Reason: Spelling - not my forty :( ) (06-20-2016, 04:45 AM)CINewb Wrote: Let's say you have a model called "Range" I prefer prefixing Controllers, Models and Views with C_, M_ and V_ respectively because the files can be immediately recognised using Sublimes list of files. Using this grouping configuration avoids confusion. Just my Song Satang thoughts
(06-20-2016, 11:14 AM)spjonez Wrote:PaulD Wrote:Wow, that is a huge number of tables. My biggest site has about 20. What on earth do they need so many tables for? I've seen small companies have 200+. I myself am well over 100. When you have a site with a lot of role based micromanagement features on both user and user_group levels, things tend to escalate!
Codeigniter is simply one of the tools you need to learn to be a successful developer. Always add more tools to your coding arsenal!
I would like to add something I consider important: https://support.google.com/manufacturers...4116?hl=en
"Throughout this article, you will see the terms item and product. Please note that we use the term item to describe a single product variant. Items are similar to products, but we assume that products can occur in multiple variations. These variations, or “product variants”, can differ by color, size, or style. In other words, an item refers to a single variation of a product. Each entry in your product data file should reflect a single item, or product variant." My interpretation is that every item that the customer picks up should have an unique ID, it could be the primary key directly (of the item, not the product) or some unique external key. An item (a concrete product with its concrete option values) should provide its own URL/page that is to be indexed. The item ID should be stored within the shopping cart and later within the created order, thus it will be always known what exactly the client has ordered, no chance for a mistake (different color, size, etc.).
i would leave this in separate Models
If i understand you correctly a possible approach could be, to work with collections - below you see an example (i simple wrote it in notepad down now - so there could be some typos - but you should be able to see the point) Range_Model PHP Code: class Range_Model extends CI_Model PHP Code: class Product_Model extends CI_Model Range Collection PHP Code: class Range_Collection extends Array_Object PHP Code: class Range_Object PHP Code: class Product_Collection extends Array_Object PHP Code: class Range_Controller and your view PHP Code: <table> |
Welcome Guest, Not a member yet? Register Sign In |