Search code examples
phpmysqlzend-frameworkzend-db

output array in right way


I use ZF1, and i need to put in title this if:

title="<?php echo isset($this->region['klu']) ? $this->region['klu'] : 'region name for  klu'?>"

where klu - is a data in r_alias row in my table

So, in my Controller i do something like this:

$region = Map_Model_Map_Factory::getFetchAll();
        $this->view->assign('region', $region);

What is getFetchAll():

static function getFetchAll()
    {
        $table = new Map_Model_Map_Table();
        $select = $table->select()
                        ->order('r_alias ASC');
        return $table->fetchAll($select);
    }

but something going wrong here, i need to have my echo region, instead i have empty page.


Solution

  • Have you tried like this

    $data['region'] = Map_Model_Map_Factory::getFetchAll();
    //echo '<pre>';
    //print_r($data['region']); // only for testing
    $this->view->assign('region', $data);
    

    Echo it in view

    echo $region['klu'];