I written a function in model:
public function plan_values($id)
{
echo $id;
$db = Zend_Db_Table::getDefaultAdapter();
$select = $db->select()
->from(array('h'=>'hosted_site_content'),array('h.hsc_value','h.hsc_plan'))
->joinLeft(array('m'=>'hosted_plan_content_mapping'),'h.hsc_type=m.hpcm_type_id')
->where('m.hpcm_type_id="'.$id.'"')
->order('h.hsc_plan asc');
$row = $db->fetchAll($select);
if (!$row)
{
throw new Exception("Could not find row $id");
}
return $row;
}
and written its controller as follow:
$planvalues = new Application_Model_DbTable_PlanList();
$this->view->planview = $planvalues->plan_values($id);
how can I pass the value to the variable in view?
$this->planview(4);
this is not giving the answer. it showing only the 4th array element of out put. Is I miss anything? Please help. I have to pass the ‘4’ value to the function plan_values.
Your
4has already been used/consumed in the call to:Looks like your call to
$planvalues->plan_values($id)should return an array of rows.You then assign this into the view as
$this->view->planview. So in your view-script,$this->planviewis precisely that array of row data. Iterate over the array to render them all.If you want to display/use that
$idvalue of 4 down in your view-script, then feel free to pass it along using$this->view->id = $id(in the controller) and then pick it up for us in the view-script using$this->id.