Welcome Guest, Not a member yet? Register   Sign In
Where to put functions / classes?
#1

[eluser]dharmy[/eluser]
Hi all

Am having problems understanding where classes should be kept in CI. I am building an application that markets mobile phones.

I would like for all of my functions (i.e. getphone, getdetails etc.) to reside in one class called Mobile - I understand that this file should be called Mobile.php and reside in the controllers folder.

Can I then have multiple functions inside Mobile.php? E.g.

Code:
public function getphone() {
   xxx
   xx
   xx
}

public function getdetails() {
   xxx
   xx
   xx
}

Or do I need to put each function in its own class?

I'd really appreciate looking at some sample code that works. I've been going through the documentation and google for a few hours, and tried all sorts of variations in the URL to find a test class, but without much luck! I've even messed around with the routes and .htaccess...

All I am trying to achieve is the following:

Code:
http://www.site.com/model/HTC-Desire/
to be re-routed to a function that accepts HTC-Desire as a parameter (as I need it for a DB lookup). The default controller (for my home page) works fine, but can't get anything to work thereafter.

Any ideas?

Thanks


Messages In This Thread
Where to put functions / classes? - by El Forum - 02-01-2012, 04:08 AM
Where to put functions / classes? - by El Forum - 02-01-2012, 04:14 AM
Where to put functions / classes? - by El Forum - 02-01-2012, 04:27 AM
Where to put functions / classes? - by El Forum - 02-01-2012, 05:28 AM
Where to put functions / classes? - by El Forum - 02-01-2012, 05:48 AM
Where to put functions / classes? - by El Forum - 02-01-2012, 01:31 PM



Theme © iAndrew 2016 - Forum software by © MyBB