up vote 1 down vote favorite

iam using the Zend framework and assign the array from the controller to view. The array is coming from execution of stored procedure result

$results = callProcedure('testprocedure', $in)//$in is an array of input values 
$view->results =$results['record'];

In The $results['record'] array iam having two values such as 'NO' and 'name' and i want to assign this values also the view.However this values will be available in the $results['record']; array. But in the view i need have the values separately i dont repeat them in the loop . if i dont do for each iam not getting the values

How do i assign these values from the controller

$view->no=???
$view->NAME=???

How do i access $results['record'] array in the view

$this->results['NO']//  it is saying undefined index 'NO'
$this->results['NAME']// it is saying undefined index 'NAME'    
link|flag

69% accept rate

1 Answer

up vote 1 down vote

To access the vies from the controller you must use $this->view->. Then from the view its $this-> because when in the view $this is the view object itself.

so try:

$results = callProcedure('testprocedure', $in)//$in is an array of input values 
$this->view->results = $results['record'];

From the controller it looks like this echoing them:

echo 'no: ' .$this->view->results['no']. '<BR />';
echo 'name: ' .$this->view->results['name'];

So do to it from the view just:

<?php
    echo 'no: ' . $this->results['no'] . '<BR />';
    echo 'name: ' . $this->results['name'];
?>
link|flag
@lznogood:$this->view->var = ???????(How should i assign the NO and Name from the array Should i say ($results['record'][NO]) – Someone Sep 7 at 17:26
1  
Edited my answer. Was more explaining the principles then coding you the answer. – Iznogood Sep 7 at 17:36
@Someone I reEdited my answer with more details. Hope it is clear to you now and you can accept my answer. – Iznogood Sep 8 at 5:10

Your Answer

get an OpenID
or
never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.