Welcome Guest, Not a member yet? Register   Sign In
Method Calling vs Redirecting?
#1

[eluser]davlyn[/eluser]
I have a controller class (for example) Forum, and in it topic and delete_post methods.

Code:
public function topic($view_id) {
    
        // loading from db
        // loading the view

}

Should I do this:

Code:
public function delete_post($post_id, $topic_id) {

    // check for stuff before deleting
    // call the model method for deleting the post
    redirect('forum/topic/'.$topic_id, 'refresh');

}

or this:

Code:
public function delete_post($post_id, $topic_id) {

    // check for stuff before deleting
    // call the model method for deleting the post
    $this->topic($topic_id);
    return; // if I don't put return it will display page twice.

}


In other words, should I redirect or call the method? Or is there even a better idea?

Also for $topic_id, is it a better idea to use a

Code:
$this->session->set_flashdata('previous_page', $this->uri->uri_string());


in the topic method so that when I call the delete_post I can read from the flashdata or to simply just put the additional param in the uri? (or something else)




Theme © iAndrew 2016 - Forum software by © MyBB