php - action after render a view (codeigniter) -


i want know if possible make different actions after render view codeigniter, like:

public function my_function() {     $data['var1'] = $this->make_one_action();     $data['var2'] = $this->make_other_action();     $this->load->view('a_view', $data);     //and now... more actions??     $this->make_database_action(); } 

what want process data of data base, don´t make wait user processing (when new view not show actions on data base user).

and little more... (a different question, related), this:

public function my_function() {     $data['var1'] = $this->make_one_action();     $data['var2'] = $this->make_other_action();     redirect(base_url()); //here difference     //and now... more actions??     $this->make_database_action(); } 

in case want redirect user new page , after make processing on data base.

thank you.

redirecting stop php script executing, if want can load page , send ajax request trigger queries
assuming using jquery: on controller add method
function executedbonpageload(){$this->make_database_action();} //add _get method name if ci version 2

and add line "a_view.php"

$(document).ready(function(){    $.ajax("index.php?/controllername/executedbonpageload()") }) 

(you'll need make bit more secured , make sure user won't trigger function many times want)


Comments