在zend中执行查询返回null

时间:2012-07-24 07:48:12

标签: php mysql zend-framework

我直接在phpmyadmin中运行此查询,它完全返回结果!! 但是当我在我的php脚本中运行此查询时,它返回 NULL

这是我的db类:

class Product extends Places_Db_Table_Row_Observable  {
    protected $_name = 'product';
    PUBLIC function getMaxSubcatProduct()
    {


        $query = $this->getAdapter()->query("select  max( c ) AS maxcount,id from ( select COUNT(*) as c 
                    ,product_sub_category_id as id  from product group by product_sub_category_id ) as max ");
        $res = $query->fetchAll();
        return $res;
    }
}

1 个答案:

答案 0 :(得分:0)

这是我的错!我在我的脚本中显示了这样的结果:

echo $this->masterMenu["id"];

但正确的方法是:

foreach ($this->masterMenu as $key => $value)
                    {
                        $masterMenu =    $value['id'];
                    }