array('name', 'email')); protected function _from(Zend_Db_Select $select = null) { if (null === $select) { $select = $this->select; } $what = array($this->_tableAlias => '*'); foreach (array('lessonsNum' => 1, 'summativeNum' => 2, 'formativeNum' => 3) as $k => $v) { $v = (int) $v; $what[$k] = new Zend_Db_Expr( "(SELECT COUNT(`File`.`id`) FROM `{$this->_getTableName('SchoolFile')}` AS `File` " . "WHERE `File`.`idUser` = `{$this->_tableAlias}`.`id` " . "AND `File`.`idLessonType` = {$v})" ); } $what['strand'] = new Zend_Db_Expr( "(SELECT COUNT(`File`.`id`) FROM `{$this->_getTableName('SchoolFile')}` AS `File` " . "WHERE `File`.`idUser` = `{$this->_tableAlias}`.`id` " . "AND `File`.`Type` = 'strand')" ); $select->from($this->pair, $what); return $select; } }