Welcome Guest, Not a member yet? Register   Sign In
Structure models for different types of products
#1

Hi,

in my app i have 3 types of products (smartwatches, smartphone and tablets). I don't know how to structure my models.

All types have some properties in common (like a name, weight...) Then smarthphones and tablets both have some properties.

What is a good way to structure the models? I would create a product-model and every other type can inherit from that. But what to do with smartphones and tablets? Where i have to store the common properties?

PHP Code:
Product_model extends CI_Model {}
Smartphone_model extends Product_model {}
Tablet_model extends Product_model {} 

Another question:
How can i get all the data from 2 database tables for an smartphone? The smartphone data are in one table (only for smartphones) and the other common data (name and so on) are in another table. In the product model there is a method find_all(), but there i get only the data from the products table. The second table for the join would be smartphone or smartwatch, but how can i get the name dynamic?
Reply


Messages In This Thread
Structure models for different types of products - by groovebird - 08-25-2015, 12:20 PM



Theme © iAndrew 2016 - Forum software by © MyBB