![]() |
User Profile URL - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: User Profile URL (/showthread.php?tid=6490) Pages:
1
2
|
User Profile URL - El Forum - 03-03-2008 [eluser]Pygon[/eluser] I'd prefer something like this: Code: class MY_Router extends CI_Router { User Profile URL - El Forum - 03-03-2008 [eluser]Michael Wales[/eluser] Yeah - my explanation above isn't the best implementation, just the easiest to understand for newer users. Personally, I extended the Router class to allow SQL queries in the route. I always place this route as the first, so it will perform the SQL query defined the route and if it returns a row, it will follow that route. An example: Code: // domain.com/walesmd User Profile URL - El Forum - 03-03-2008 [eluser]~Chris~[/eluser] Hmmm. I see. Yes, what you all say makes sense. I would have never thought about extending the router class, especially adding sql queries into the router. genius. Ill have to read more on extending the router class so I can do the same. Thanks. User Profile URL - El Forum - 03-03-2008 [eluser]Pygon[/eluser] [quote author="Michael Wales" date="1204599848"]Yeah - my explanation above isn't the best implementation, just the easiest to understand for newer users. Personally, I extended the Router class to allow SQL queries in the route. I always place this route as the first, so it will perform the SQL query defined the route and if it returns a row, it will follow that route. An example: Code: // domain.com/walesmd Rather clean implementation, though i'd hate querying the db on every hit (even when it's not needed). User Profile URL - El Forum - 03-03-2008 [eluser]Code Arachn!d[/eluser] My biggest concern would be issues of sql injection with placing sql in the routes... theoretically parsing from a db would be a lot faster than running IO on the local drive (or in the case of a farm - having to reach out to another server for IO would even worse for scalability). User Profile URL - El Forum - 03-03-2008 [eluser]Pygon[/eluser] Not sure about that, and don't find it likely that you'll be running controllers on different servers and reaching across them anyway. I don't know directly offhand -- but I would assume a cached file_exists is going to be much faster than a row lookup. User Profile URL - El Forum - 03-04-2008 [eluser]~Chris~[/eluser] my understanding of codeigniter has deepened. User Profile URL - El Forum - 03-04-2008 [eluser]Pygon[/eluser] Yes -- It's always good to run into things you don't know how to do. Working out problems has caused me many times to read and better understand the underlying framework. The more I use CI, the more I realize just how flexible it is, unlike many other frameworks. I do feel there are some areas in which this flexibility could be improved, such as the way the router works, but overall I find everything to be incredibly flexible. User Profile URL - El Forum - 05-04-2008 [eluser]Unknown[/eluser] This: Quote:$route["sql[SELECT id FROM users WHERE username = $1]"] = "user/profile/$1"; is beautiful, thanks a lot Michael, I did generate routes based on sql queries, but in an ugly, non-CI way. This is really amazing how much good stuff one can squeeze out of CI. I'm happy, cheers :lol: |