Welcome Guest, Not a member yet? Register   Sign In
Upload multiple images, store img paths & info to db
#4

[eluser]Narkboy[/eluser]
Ok - it this situation I would simply drive around the entire thing.

Anything to do with your database, move into a model. Any method that accesses the database to send or retrieve data should be in that model.

The do_upload() method could also go in a model (different one) but I would normally leave it in the controller unless it's being used in more than one place. Lazy, but defensible!

So your controller goes:

Code:
function do_upload()
{
    // upload the image, store path and file name etc as $info

    // now call the model and get it to drop to the db:
    $this->my_db_model->insert_to_db($info);

    // Now error check the db insert to ensure that it worked.

    // Now show the user something.
}

That way, the task is done logically, in order, and by the correct parts of the MVC framework. You can resue the insert_to_db function for uploads in other places as well.

Smile


Messages In This Thread
Upload multiple images, store img paths & info to db - by El Forum - 04-13-2010, 12:11 PM
Upload multiple images, store img paths & info to db - by El Forum - 04-13-2010, 12:31 PM
Upload multiple images, store img paths & info to db - by El Forum - 04-14-2010, 01:39 AM
Upload multiple images, store img paths & info to db - by El Forum - 04-27-2010, 01:45 AM



Theme © iAndrew 2016 - Forum software by © MyBB