Welcome Guest, Not a member yet? Register   Sign In
Pass data between functions
#1

[eluser]Stuart Marsh[/eluser]
Can anybody tell me how I can pass data between controllers quickly and efficiently?
I have two controllers. Controller A displays a form and validates the data. I want controller A to redirect the page and pass the form data to controller B.
I dont really want to pass the data through the URI, but will if there is no other way.
Anybody got any suggestions?

Cheers.
#2

[eluser]sophistry[/eluser]
store in db or session.
#3

[eluser]Michael Wales[/eluser]
Why would you want to transfer data from Controller to Controller - the point of the Controller is so all of your work with a particular set of data is stored within one location.

For example, a controller named users. It would have everything to do with users: register, login, logout, profiles - that is it's purpose.

Regardless, if you really wanted to do it (and break the MVC model) - store it in a DB or session.
#4

[eluser]Stuart Marsh[/eluser]
Thanks for the suggestions.
Walesmd - Gettin myself confused.
I want to pass values between functions not controllers.
#5

[eluser]Michael Wales[/eluser]
Oh that's easy then - to call a function from another function just call it as such:

Code:
function get_name() {
  $a = 'bob';
  $str = $this->say_hi($a);
  return $str;
  }

  function say_hi($name) {
    return 'Hello, ' . $name;
  }
#6

[eluser]Stuart Marsh[/eluser]
Cool.
Cheers mate.




Theme © iAndrew 2016 - Forum software by © MyBB