Welcome Guest, Not a member yet? Register   Sign In
Sorting with Code Igniter
#1

[eluser]Unknown[/eluser]
Hello I want to make a sorting script with code igniter.
I'm sending arguments to method by URL (sort/db_field/sort_type)

example: sort/title/desc

But I think it is bad solution, becouse for example if someone wrote bad value as db_field (ex. title123) then
Code Igniter will generate error like "Unknown Field" with full query to database.

It is dangerous becouse noone should know names of tables etc.

Is there any other solution to make sorting like this?
If not, meybe I can disable that error function and made redirect there? but how?
Give me some advices please.

~reptilerex
#2

[eluser]Frank Wong[/eluser]
You can control error reporting in your index.php. Obviously, for production, it should be set to
Code:
error_reporting(0);

Also, you can use active records to get field and table metadata in order to determine if the user has entered a request that will not generate a sql error.
#3

[eluser]toopay[/eluser]
Look at your index.php for that error_reporting config. But actually, with some tweak, you doesn't really need that. You actually can do some inspection of requested parameter, to see if there matches field name and if yes if there any mathed result for related value. Thats way, you can filtering out the invalid input, before submit anything to your database. In fact, thats the better way, rather than sending any GET parameter directly into your model.




Theme © iAndrew 2016 - Forum software by © MyBB