![]() |
question about writing model - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: question about writing model (/showthread.php?tid=12523) |
question about writing model - El Forum - 10-22-2008 [eluser]dexcell[/eluser] hello, i would like to ask if my approach of writing is correct. i have 2 models, let's name it entries_model and groups_model entries_model do the low handling to entries table. groups_model do the low handling to group table. then in one of functions of entries model, it needs to connect to group table to check something, the question: should i write (connecting to group table manually) in one of entries_model function? or should i just load group_model and call the method? for illustration (if i load the group_model, it works tough i don't know if it's correct way since i'm new to CI): Code: class Entries_model extends Model question about writing model - El Forum - 10-22-2008 [eluser]lmv4321[/eluser] Is there a reason that you are using separate databases instead of separate tables in the same database? question about writing model - El Forum - 10-22-2008 [eluser]dexcell[/eluser] [quote author="lmv4321" date="1224732312"]Is there a reason that you are using separate databases instead of separate tables in the same database?[/quote] whoops sorry, i mean table. updated the post. *maybe it was midnight when i wrote that, you know :roll: * question about writing model - El Forum - 10-22-2008 [eluser]Colin Williams[/eluser] I think it's okay for models to make use of other models in some instances, but I see no problem with, say, the Entry model doing some queries that JOIN the groups tables. I'd keep most write/update stuff separate if possible and if it doesn't hinder performance (amount of queries) too much. question about writing model - El Forum - 10-23-2008 [eluser]dexcell[/eluser] thanks |