original_string: public function getSelect()
      {
          $select = $this->db->select();
  
          $fields['answered'] = new \Zend_Db_Expr("SUM(
              CASE
              WHEN grc_success = 1 AND gto_completion_time IS NOT NULL
              THEN 1 ELSE 0 END
              )");
          $fields['missed']   = new \Zend_Db_Expr('SUM(
              CASE
              WHEN grc_success = 1 AND
                   gto_completion_time IS NULL AND
                   gto_valid_until < CURRENT_TIMESTAMP AND
                   (gto_valid_from IS NOT NULL AND gto_valid_from <= CURRENT_TIMESTAMP)
              THEN 1 ELSE 0 END
              )');
          $fields['open']   = new \Zend_Db_Expr('SUM(
              CASE
              WHEN grc_success = 1 AND gto_completion_time IS NULL AND
                  gto_valid_from <= CURRENT_TIMESTAMP AND
                  (gto_valid_until >= CURRENT_TIMESTAMP OR gto_valid_until IS NULL)
              THEN 1 ELSE 0 END
              )');
          $fields['total'] = new \Zend_Db_Expr('SUM(
              CASE
              WHEN grc_success = 1 AND (
                      gto_completion_time IS NOT NULL OR
                      (gto_valid_from IS NOT NULL AND gto_valid_from <= CURRENT_TIMESTAMP)
                  )
              THEN 1 ELSE 0 END
              )');
          /*
          $fields['future'] = new \Zend_Db_Expr('SUM(
              CASE
              WHEN grc_success = 1 AND gto_completion_time IS NULL AND gto_valid_from > CURRENT_TIMESTAMP
              THEN 1 ELSE 0 END
              )');
          $fields['unknown'] = new \Zend_Db_Expr('SUM(
              CASE
              WHEN grc_success = 1 AND gto_completion_time IS NULL AND gto_valid_from IS NULL
              THEN 1 ELSE 0 END
              )');
          $fields['is']      = new \Zend_Db_Expr("'='");
          $fields['success'] = new \Zend_Db_Expr('SUM(
              CASE
              WHEN grc_success = 1
              THEN 1 ELSE 0 END
              )');
          $fields['removed'] = new \Zend_Db_Expr('SUM(
              CASE
              WHEN grc_success = 0
              THEN 1 ELSE 0 END
              )');
          // */
  
          $fields['filler'] = new \Zend_Db_Expr('COALESCE(gems__track_fields.gtf_field_name, gems__groups.ggp_name)');
  
          $select = $this->db->select();
          $select->from('gems__tokens', $fields)
                  ->joinInner('gems__reception_codes', 'gto_reception_code = grc_id_reception_code', array())
                  ->joinInner('gems__rounds', 'gto_id_round = gro_id_round',
                          array('gro_round_description', 'gro_id_survey'))
                  ->joinInner('gems__surveys', 'gro_id_survey = gsu_id_survey',
                          array('gsu_survey_name'))
                  ->joinInner('gems__groups', 'gsu_id_primary_group =  ggp_id_group', array())
                  ->joinLeft('gems__track_fields', 'gto_id_relationfield = gtf_id_field AND gtf_field_type = "relation"', array())
                  ->group(array('gro_id_order', 'gro_round_description', 'gsu_survey_name', 'filler'));
  
          $filter = $this->getSearchFilter();
          if (array_key_exists('fillerfilter', $filter)) {
              $select->having('filler = ?', $filter['fillerfilter']);
          }
  
          return $select;
      }
code: public function getSelect()
      {
          $select = $this->db->select();
  
          $fields['answered'] = new \Zend_Db_Expr("SUM(
              CASE
              WHEN grc_success = 1 AND gto_completion_time IS NOT NULL
              THEN 1 ELSE 0 END
              )");
          $fields['missed']   = new \Zend_Db_Expr('SUM(
              CASE
              WHEN grc_success = 1 AND
                   gto_completion_time IS NULL AND
                   gto_valid_until < CURRENT_TIMESTAMP AND
                   (gto_valid_from IS NOT NULL AND gto_valid_from <= CURRENT_TIMESTAMP)
              THEN 1 ELSE 0 END
              )');
          $fields['open']   = new \Zend_Db_Expr('SUM(
              CASE
              WHEN grc_success = 1 AND gto_completion_time IS NULL AND
                  gto_valid_from <= CURRENT_TIMESTAMP AND
                  (gto_valid_until >= CURRENT_TIMESTAMP OR gto_valid_until IS NULL)
              THEN 1 ELSE 0 END
              )');
          $fields['total'] = new \Zend_Db_Expr('SUM(
              CASE
              WHEN grc_success = 1 AND (
                      gto_completion_time IS NOT NULL OR
                      (gto_valid_from IS NOT NULL AND gto_valid_from <= CURRENT_TIMESTAMP)
                  )
              THEN 1 ELSE 0 END
              )');
          /*
          $fields['future'] = new \Zend_Db_Expr('SUM(
              CASE
              WHEN grc_success = 1 AND gto_completion_time IS NULL AND gto_valid_from > CURRENT_TIMESTAMP
              THEN 1 ELSE 0 END
              )');
          $fields['unknown'] = new \Zend_Db_Expr('SUM(
              CASE
              WHEN grc_success = 1 AND gto_completion_time IS NULL AND gto_valid_from IS NULL
              THEN 1 ELSE 0 END
              )');
          $fields['is']      = new \Zend_Db_Expr("'='");
          $fields['success'] = new \Zend_Db_Expr('SUM(
              CASE
              WHEN grc_success = 1
              THEN 1 ELSE 0 END
              )');
          $fields['removed'] = new \Zend_Db_Expr('SUM(
              CASE
              WHEN grc_success = 0
              THEN 1 ELSE 0 END
              )');
          // */
  
          $fields['filler'] = new \Zend_Db_Expr('COALESCE(gems__track_fields.gtf_field_name, gems__groups.ggp_name)');
  
          $select = $this->db->select();
          $select->from('gems__tokens', $fields)
                  ->joinInner('gems__reception_codes', 'gto_reception_code = grc_id_reception_code', array())
                  ->joinInner('gems__rounds', 'gto_id_round = gro_id_round',
                          array('gro_round_description', 'gro_id_survey'))
                  ->joinInner('gems__surveys', 'gro_id_survey = gsu_id_survey',
                          array('gsu_survey_name'))
                  ->joinInner('gems__groups', 'gsu_id_primary_group =  ggp_id_group', array())
                  ->joinLeft('gems__track_fields', 'gto_id_relationfield = gtf_id_field AND gtf_field_type = "relation"', array())
                  ->group(array('gro_id_order', 'gro_round_description', 'gsu_survey_name', 'filler'));
  
          $filter = $this->getSearchFilter();
          if (array_key_exists('fillerfilter', $filter)) {
              $select->having('filler = ?', $filter['fillerfilter']);
          }
  
          return $select;
      }
code_tokens: public function getSelect ( ) { $ select = $ this -> db -> select ( ) ; $ fields [ 'answered' ] = new \ Zend_Db_Expr ( "SUM(
              CASE
              WHEN grc_success = 1 AND gto_completion_time IS NOT NULL
              THEN 1 ELSE 0 END
              )" ) ; $ fields [ 'missed' ] = new \ Zend_Db_Expr ( 'SUM(
              CASE
              WHEN grc_success = 1 AND
                   gto_completion_time IS NULL AND
                   gto_valid_until < CURRENT_TIMESTAMP AND
                   (gto_valid_from IS NOT NULL AND gto_valid_from <= CURRENT_TIMESTAMP)
              THEN 1 ELSE 0 END
              )' ) ; $ fields [ 'open' ] = new \ Zend_Db_Expr ( 'SUM(
              CASE
              WHEN grc_success = 1 AND gto_completion_time IS NULL AND
                  gto_valid_from <= CURRENT_TIMESTAMP AND
                  (gto_valid_until >= CURRENT_TIMESTAMP OR gto_valid_until IS NULL)
              THEN 1 ELSE 0 END
              )' ) ; $ fields [ 'total' ] = new \ Zend_Db_Expr ( 'SUM(
              CASE
              WHEN grc_success = 1 AND (
                      gto_completion_time IS NOT NULL OR
                      (gto_valid_from IS NOT NULL AND gto_valid_from <= CURRENT_TIMESTAMP)
                  )
              THEN 1 ELSE 0 END
              )' ) ; /*
          $fields['future'] = new \Zend_Db_Expr('SUM(
              CASE
              WHEN grc_success = 1 AND gto_completion_time IS NULL AND gto_valid_from > CURRENT_TIMESTAMP
              THEN 1 ELSE 0 END
              )');
          $fields['unknown'] = new \Zend_Db_Expr('SUM(
              CASE
              WHEN grc_success = 1 AND gto_completion_time IS NULL AND gto_valid_from IS NULL
              THEN 1 ELSE 0 END
              )');
          $fields['is']      = new \Zend_Db_Expr("'='");
          $fields['success'] = new \Zend_Db_Expr('SUM(
              CASE
              WHEN grc_success = 1
              THEN 1 ELSE 0 END
              )');
          $fields['removed'] = new \Zend_Db_Expr('SUM(
              CASE
              WHEN grc_success = 0
              THEN 1 ELSE 0 END
              )');
          // */ $ fields [ 'filler' ] = new \ Zend_Db_Expr ( 'COALESCE(gems__track_fields.gtf_field_name, gems__groups.ggp_name)' ) ; $ select = $ this -> db -> select ( ) ; $ select -> from ( 'gems__tokens' , $ fields ) -> joinInner ( 'gems__reception_codes' , 'gto_reception_code = grc_id_reception_code' , array ( ) ) -> joinInner ( 'gems__rounds' , 'gto_id_round = gro_id_round' , array ( 'gro_round_description' , 'gro_id_survey' ) ) -> joinInner ( 'gems__surveys' , 'gro_id_survey = gsu_id_survey' , array ( 'gsu_survey_name' ) ) -> joinInner ( 'gems__groups' , 'gsu_id_primary_group =  ggp_id_group' , array ( ) ) -> joinLeft ( 'gems__track_fields' , 'gto_id_relationfield = gtf_id_field AND gtf_field_type = "relation"' , array ( ) ) -> group ( array ( 'gro_id_order' , 'gro_round_description' , 'gsu_survey_name' , 'filler' ) ) ; $ filter = $ this -> getSearchFilter ( ) ; if ( array_key_exists ( 'fillerfilter' , $ filter ) ) { $ select -> having ( 'filler = ?' , $ filter [ 'fillerfilter' ] ) ; } return $ select ; }
docstring: Select creation function, allowes overruling in child classes
  
  @return \Zend_Db_Select
docstring_tokens: Select creation function allowes overruling in child classes