• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pass data between functions

[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?


store in db or session.

[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.

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

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

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

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

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

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.