Welcome Guest, Not a member yet? Register   Sign In
How to map upload.php and my table information
#2

[eluser]iainco[/eluser]
The way I would think about this is, try to make the controller do most of the work - leave the model to pretty much only call DB queries.

Your first idea - "Should I create an array with same index as column names, give it values and then pass it to model" seems to work for me".

If I'm reading it right you could do this:

Controllor:
Code:
function saveUpload()
{
   $d = array(
     file_name      => '',
     file_type      => '',
     file_path      => '',
     full_path      => '',
     raw_name       => '',
     orig_name      => '',
     file_ext       => '',
     file_size      => '',
     is_image       => '',
     image_width    => '',
     image_height   => '',
     image_type     => '',
     image_size_str => ''
   );

   $this->load->model('upload/save_model');
   $this->save_model->saveUpload($d);
}

Model:
Code:
function saveUpload($d)
{
   $this->db->insert('uploads', $d);
}

Obviously this is a very simple example, but if you get an array with the indexes as the table columns you can use the ActiveRecord insert method.

You could have the method that uploads the file return an array of the information, which you then pass into another method to secure/santize, then finally call the saveUpload method.

That's my take on it, but please understand I'm a CI newb!

Everyone feel free to tell me I'm talking rubbish!

Cheers


Messages In This Thread
How to map upload.php and my table information - by El Forum - 12-17-2008, 05:24 PM
How to map upload.php and my table information - by El Forum - 12-17-2008, 06:44 PM
How to map upload.php and my table information - by El Forum - 12-17-2008, 07:08 PM
How to map upload.php and my table information - by El Forum - 12-17-2008, 07:25 PM
How to map upload.php and my table information - by El Forum - 12-17-2008, 07:30 PM
How to map upload.php and my table information - by El Forum - 12-17-2008, 07:37 PM
How to map upload.php and my table information - by El Forum - 12-17-2008, 07:44 PM
How to map upload.php and my table information - by El Forum - 12-18-2008, 07:12 AM



Theme © iAndrew 2016 - Forum software by © MyBB