mulrali
mulrali

Reputation: 29

how i can pass data from coutroller to view in zend famwork

I used zendframwork, this is my code in controller

      $getRows = $this->MgGeneral->select();
            foreach($getRows as $value) {
                var_dump($value);
            }

i want send $getRow to view but it's in object (array in array), so what i need pass to view true is $value that i var_dump it's show

enter image description here

So how i can pass $value to view ?

Upvotes: 0

Views: 55

Answers (3)

mulrali
mulrali

Reputation: 29

Thanks to @Harry

by your answer now i get correct by

    $passtoview = array();
    $getRows = $this->MgGeneral->select();
    foreach($getRows as $value) {
           $passtoview[] = $value;
    };
    var_dump($passtoview);

Upvotes: 2

raygo
raygo

Reputation: 1398

In your controller do:

$this->view->value = $value;

and in the view you can get it by doing:

$this->value;

Upvotes: 1

Harry
Harry

Reputation: 81

In your controller, just pass the value to:

$this->view->yourVariable = $yourValue;

In your view, you can access the value like this:

var_dump($this->yourVariable); /* you'll get $yourValue */

Bring to your code:

$getRows = $this->MgGeneral->select();
foreach($getRows as $value) {
    $this->view->value[] = $value;
};

Upvotes: 2

Related Questions