0

我直接在 phpmyadmin 中运行这个查询,它完美地返回了结果!!但是当我在我的 php 脚本中运行这个查询时,它返回NULL

这是我的数据库类:

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;
    }
}
4

1 回答 1

0

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

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

但正确的方法是:

foreach ($this->masterMenu as $key => $value)
                    {
                        $masterMenu =    $value['id'];
                    }
于 2012-07-26T06:31:40.950 回答