Welcome Guest, Not a member yet? Register   Sign In
use segment to determine which database to use - but how ?
#1

[eluser]cinewbie81[/eluser]
Hi all,

i want to use my 1st segment url to determine which database should i use ..
for eg:

i) www.my-site.com/dell/userlisting
It should linked me to database 'dell' and show me the user listing in dell database ..

ii) www.my-site.com/fujitsu/userlisting
It should linked me to database 'fujitsu' and show me the user listing in fujitsu database

In the link url show above, userlisting will be the class instead of the function .. the segment after userlisting will be the function instead of parameter .. How can i do it ?

Thanks
#2

[eluser]xwero[/eluser]
Code:
$route['([a-z]+)/([a-z]+)/([a-z]+)'] = "$2/$3/$1";
#3

[eluser]Chris Newton[/eluser]
in addition to $route, you could also use uri_to_assoc for any additional segments you wanna pass. I find that helps quite a bit rather than using segment_3, etc.
#4

[eluser]cinewbie81[/eluser]
Hi,

when i type the url www.my-site.com/dell/userlisting , it said "The page you requested was not found." . This is because there's no controller class call "Dell" in my system. In my case, supposely dell isn't a class, userlisting will be the class however .. where should i set so that the system will ignore the 1st segment and treat the 2nd segment as the controller class instead of the 1st one ?




Theme © iAndrew 2016 - Forum software by © MyBB