Welcome Guest, Not a member yet? Register   Sign In
Libraries or Models, favouritism?
#3

[eluser]jbowman[/eluser]
For your controller why not

Code:
artist.php -> index() (my profile, if no session, redirect to registration or front page)
           -> blog($uid = "use_session")
           -> blog_entry($id)
           -> gallery($uid = "use_session")
           -> artwork($id)
.. more for adding comments on an artwork, comment the profile page, etc. etc.

Play with routes a little and get blog/add, blog/del, and blog/edit...

For models vs libraries, I'll give you an example of what I'm working on now.

I have an idea I'm working on where my site is going to authenticate against a jabber server, and also get profile information from there.

So, I grabbed an existing jabber library I found, and modified it a little to turn it into an acceptable library for CI.

Then I created a jabber.php in my config folder which includes the jabber host and port information (more information may be added later, all I need right now). This then gets autoloaded.

Now, I'm working on my jabber_model.php. Literally started on this last night. Currently is has 1 and a half methods. The jabber library is loaded in the constructor.

connect() - uses the information from the config file to connect to a jabber server
authenticate($username, $password) - calls the connect method to establish a connection to the jabber server, then authenticates based on passed variables.

So, as you can see, the library holds all the advanced protocol implementations, where as my model runs on top of that to plug in and retrieve information. By using generic methods like "connect, authenticate (you know I should change this to log in), logout, etc etc", I can swap out models under my controllers if I decide that I really don't want to use jabber after all.


Messages In This Thread
Libraries or Models, favouritism? - by El Forum - 02-25-2008, 08:28 AM
Libraries or Models, favouritism? - by El Forum - 02-25-2008, 10:41 AM
Libraries or Models, favouritism? - by El Forum - 02-25-2008, 10:46 AM
Libraries or Models, favouritism? - by El Forum - 02-25-2008, 02:59 PM
Libraries or Models, favouritism? - by El Forum - 02-25-2008, 04:54 PM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 01:33 AM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 01:43 AM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 02:13 AM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 02:24 AM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 03:05 AM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 03:20 AM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 03:34 AM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 03:42 AM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 03:50 AM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 04:26 AM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 08:08 AM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 08:40 AM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 10:23 AM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 10:33 AM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 11:34 AM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 01:01 PM
Libraries or Models, favouritism? - by El Forum - 02-26-2008, 01:41 PM
Libraries or Models, favouritism? - by El Forum - 03-29-2008, 10:14 PM
Libraries or Models, favouritism? - by El Forum - 03-29-2008, 10:26 PM
Libraries or Models, favouritism? - by El Forum - 03-29-2008, 10:30 PM



Theme © iAndrew 2016 - Forum software by © MyBB