i've tried this :

        public function countLevels() {
                $select = $this->select();
                $select->distinct();
                $select->from($this,array('nb' => 'COUNT(idparent)'));
                return $this->fetchAll($select);
        }

a call to the __toString method gives this sql statement :

SELECT DISTINCT COUNT(idparent) AS `nb` FROM `menu_element`

wich is not the one i'd like to perform :

select count(distinct idparent) from menu_element

i'm still looking for...

thanks for help


Denis Fohl a écrit :
Hi all,

i can't manage myself to get it work :

    public function countLevels() {
        $select = $this->select();
        $select->from($this,'COUNT(DISTINCT idparent');
        return $this->fetchAll($select);
    }

this method is declared in a db_table object and i've got the following error : Zend_Db_Statement_Exception: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'menu_element.COUNT(DISTINCT idparent' in 'field list' in E:\phplib\Zend\Db\Statement\Pdo.php on line 238

I've look to adding expression colomuns in documentation but can't find the way.

Thank you for your help





--
Denis Fohl
--------------
df-info
06 84 38 21 99

Reply via email to