Problem with uri segments |
[eluser]Atharva[/eluser]
Hi, My problem with URI segments and may occur if user is destructive minded ( mirk: ) The initial link would be like Code: http://domain.com/index.php/controller/index/ Code: http://domain.com/index.php/controller/index/resTakeOut/DESC/1/0 So the current uri segments are 1=>controller 2=>index 3=>resTakeOut 4=>DESC 5=>1 6=>0 So the problem I identify during destructive testing is that if I deletes a uri segment then it gives me a db error eg: http://domain.com/index.php/controller/i...keOut//1/0[/code] will give me a db error like Code: SELECT SQL_CALC_FOUND_ROWS * FROM cs_table where cId= 1 order by(resTakeOut) 1 LIMIT 0,10 1=>controller 2=>index 3=>resTakeOut 4=>1 5=>0 So as you can see it takes uri segment 4 for order by (desc/asc) clause in the query which now will be '1' which is invalid for sql query. So the whole problem lies in the fact that CI don't recognizes the empty uri between //. I have taken the default vales for the function index but it will not help since the uri segment 5 will be treated as segment 4. So I am wondering if there is any solution for this? I had a look at uri class but not sure how I can overcome this problem. I appreciate your help. Thanks.
[eluser]Dam1an[/eluser]
You could use routes for this Make sure to check that segment 3 is a string, that segment 4 is either ASC or DESC, and that segments 5 and 6 are numeric If I have some time later (and what I said above wasn;t very clear) i'll come up with an example
[eluser]Atharva[/eluser]
[quote author="Dam1an" date="1240924454"]You could use routes for this Make sure to check that segment 3 is a string, that segment 4 is either ASC or DESC, and that segments 5 and 6 are numeric If I have some time later (and what I said above wasn;t very clear) i'll come up with an example[/quote] Thanks. But I am not sure whether routing will help. Can you show any example for it? Also, my site is quite big so I was wondering if there is any another simpler solution for this.
[eluser]Dam1an[/eluser]
A simpler solution would be to use a javascript table sorter, which would also save having to do another database query each time (Although I've never used one, so can't really recommend it, but something to look into)
[eluser]Dam1an[/eluser]
As promised, here's some quick routes I threw together (not tested) Code: // Everything is specified Make sense?
[eluser]Atharva[/eluser]
Thanks Dam. But I got it working some another way. Thanks for your help. |
Welcome Guest, Not a member yet? Register Sign In |