_db->select(); $select->from($this->_getPair('GalleryImage', 'gi'), 'COUNT(`gi`.`id`)'); $select->where('`gi`.`galleryId` = `g`.`id`'); if (null !== $visible) { $select->where('`gi`.`enabled` = ?', ($visible) ? 'y' : 'n'); } return $select; } protected function _getVisibleImagesCountSelect() { return $this->_getImagesCountSelect(true); } }