+ Post New Thread
Results 1 to 3 of 3
Web Development Thread, CodeIgniter best practice for accessing multiple tables in single view in Coding and Web Development; I'm building a proof of concept application which like many db applications will need at times to pull in data ...
  1. #1

    localzuk's Avatar
    Join Date
    Dec 2006
    Location
    Minehead
    Posts
    17,818
    Thank Post
    517
    Thanked 2,473 Times in 1,916 Posts
    Blog Entries
    24
    Rep Power
    836

    CodeIgniter best practice for accessing multiple tables in single view

    I'm building a proof of concept application which like many db applications will need at times to pull in data from multiple tables and display them in a single view.

    So, my question is this - what's best practice?

    Obviously, CodeIgniter is an MVC framework, so what jumps to mind is that each table should have its own model, regardless of what I do with them later.

    Then I'd load the models for the tables I want in the controller, and then the view will read from those different arrays of data.

    Would this be best practice?

  2. #2
    jamiess's Avatar
    Join Date
    Oct 2009
    Location
    Balsall Common
    Posts
    72
    Thank Post
    10
    Thanked 20 Times in 17 Posts
    Rep Power
    14
    It's what I would do, however you could all ways have a model for each action, say handling bookings, which could then interact with multiple tables.

  3. #3

    webman's Avatar
    Join Date
    Nov 2005
    Location
    North East England
    Posts
    8,406
    Thank Post
    640
    Thanked 961 Times in 661 Posts
    Blog Entries
    2
    Rep Power
    324
    Yes, typically, most tables should have their own model to handle any operations that use it. Call the models from the controller, and pass the returned data to the view.

    If you are using both tables via a JOIN in a single query, then put the function for that query wherever it makes most sense in the context of what you're doing

SHARE:
+ Post New Thread

Similar Threads

  1. Best practice for setting up programs for 32-bit and 64-bit use
    By JohnnyJet in forum Windows Server 2008 R2
    Replies: 0
    Last Post: 28th November 2012, 10:22 AM
  2. Best practice for profiles
    By sadams1980 in forum Windows Server 2008 R2
    Replies: 1
    Last Post: 8th August 2012, 01:18 AM
  3. Best practice for use and number of servers
    By mistersparky in forum Windows Server 2008 R2
    Replies: 3
    Last Post: 1st June 2012, 01:31 PM
  4. Best practices for server services?
    By Resolver in forum Windows Server 2000/2003
    Replies: 3
    Last Post: 28th July 2011, 02:37 AM
  5. Monthly reporting best practice for IT manager
    By albertwt in forum How do you do....it?
    Replies: 5
    Last Post: 25th August 2010, 12:49 PM

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •