Welcome Guest, Not a member yet? Register   Sign In
basic but....
#17

[eluser]nmweb[/eluser]
The CI validation class has several issues most of which can be solved by being more OO but it would involve a rewrite. For one think that a validation class should do what I expect it to do, namely validate and not assume that the page contains $_POST data or something. We should pass the data it should validate, for all I care I want to validate the data coming from the database once again. This means a simple
Code:
$validate=new Validation($_POST); //or $_GET or any array
$validate->add_rule('field','rule'); //or something
if($validate->validate())
{}
This is a more intuitive approach to validation, I think. It gives you more freedom as to where you can use it, the current library can only really be used in the controller. This is an historical issue I assume since CodeIgniter for a while didn't have models.

I think uploads should be handled by the model in that sense that you pass the $_FILES to a model and it should handle its storage. Ideally I would have an object representing the file
Code:
class Image_Model extends File_Model{}
class Textfile_Model extends File_Model{}

$image=new Image_Model('image001.gif');
$image->rename('image002.gif'); //rename inherited from file_model
echo $image->get_location; // from file_model

$image->resize(array(50,100)); //method in Image_Model
$image->save(); //method in Image_Model, overridden from File_Model

$file=new Textfile_Model('some_text.txt');
$file->rename('something.txt');
$file->append_text('some extra text at the end of the file');
$file->save(); //method in Textfile_Model, overridden from File_Model

This would be my approach. I love OOP Smile


Messages In This Thread
basic but.... - by El Forum - 03-11-2008, 11:46 AM
basic but.... - by El Forum - 03-11-2008, 11:57 AM
basic but.... - by El Forum - 03-11-2008, 04:24 PM
basic but.... - by El Forum - 03-12-2008, 03:30 AM
basic but.... - by El Forum - 03-12-2008, 03:41 AM
basic but.... - by El Forum - 03-12-2008, 04:36 AM
basic but.... - by El Forum - 03-12-2008, 04:39 AM
basic but.... - by El Forum - 03-12-2008, 05:00 AM
basic but.... - by El Forum - 03-12-2008, 06:30 AM
basic but.... - by El Forum - 03-12-2008, 06:55 AM
basic but.... - by El Forum - 03-13-2008, 02:25 AM
basic but.... - by El Forum - 03-13-2008, 02:58 AM
basic but.... - by El Forum - 03-13-2008, 04:11 AM
basic but.... - by El Forum - 03-13-2008, 05:04 AM
basic but.... - by El Forum - 03-13-2008, 06:13 AM
basic but.... - by El Forum - 03-13-2008, 06:41 AM
basic but.... - by El Forum - 03-13-2008, 07:12 AM
basic but.... - by El Forum - 03-13-2008, 02:18 PM



Theme © iAndrew 2016 - Forum software by © MyBB