_tableName}` WHERE `id` = " . $this->getPrimaryKey(); return $this->db->fetchOne($sql); } protected function _from(Zend_Db_Select $select = null) { if (null === $select) { $select = $this->select; } $what = array($this->_tableAlias => '*'); $what['contactsNum'] = new Zend_Db_Expr( "(SELECT COUNT(`User`.`id`) FROM `{$this->_getTableName('User')}` AS `User` " . "WHERE `User`.`idSchool` = `{$this->_tableAlias}`.`id`)" ); $select->from($this->pair, $what); return $select; } }