我对 OOPS 和 Zend 很陌生。我正在将 Web 应用程序代码的一部分转换为 Zend 框架,我不能在这里发布所有代码,因为它很长。我在下面的代码中创建了一个模型(我只能发布两个函数),我想从控制器访问函数内部的变量,然后在 HTML 表中打印出来(我想我将不得不使用“视图”那”,下面是我的模型:
  public function getVenueTypes()
 {
$poiTypes = array();
    if($this->_cache)
    {
        $key = $this->getCacheKey()."poiTypes_stats:{$this->language}";
    }
    if(!$poiTypes)
    {
        $sql = "SELECT poi_type_id, poi_type_name_".$this->language."
                AS
                poi_type_name
                FROM
                poi_types
                ORDER BY
                poi_type_name_".$this->language." ASC";
        $result = mysql_query($sql);
        if(!$result)
        {
            $message  = 'Invalid query: ' . mysql_error() . "\n";
            $message .= "Whole query: \n\n$sql\n";
            die($message);
        }
        while($row = mysql_fetch_array($result))
        {
            $poiTypes[] = array('id' => $row['poi_type_id'] ,'name' => $row['poi_type_name']);
        }
        print_r($poiTypes);
        if ($this->_cache)
        {
            $this->_cache->save($key, $poiTypes);               
        }    
    } 
foreach($poiTypes as $poiType)
    {
        $count_type = null;
        if($this->_cache)
        {
    $key = $this->getCacheKey()."poiTypeCount:{$poiType['id']}:{$this->metro_id}";
            $count_type = $this->_cache->load($key);
        }
        if(!$count_type)
        {
    $sql = "SELECT COUNT(*) FROM
                poi
                WHERE
                find_in_set('{$poiType['id']}', poi_type_id_array)
                AND poi_status = 1 AND poi_address_prefecture_id = '$this->metro_id'";
            $result = mysql_query($sql) or die(mysql_error());
        }  
        if(!$result)
            {
                $message  = 'Invalid query: ' . mysql_error() . "\n";
                $message .= "Whole query: \n\n$sql\n";
                die($message);
            }
        while($count = mysql_fetch_array($result))
        {
            $count_type[$poiType['id']][$this->metro_id] = $count['COUNT(*)'];
        }
        if($this->_cache)
        {
    $this->_cache->save($key, $count_type);
        }
    } 
 } 
任何帮助都非常感谢,我希望我足够清楚并提前感谢。