original_string: protected static function get_load_sql($quizid, $rules, $basefields) {
          $allfields = $basefields;
          $alljoins = '{quiz} quiz';
          $allparams = array('quizid' => $quizid);
  
          foreach ($rules as $rule) {
              list($fields, $joins, $params) = $rule::get_settings_sql($quizid);
              if ($fields) {
                  if ($allfields) {
                      $allfields .= ', ';
                  }
                  $allfields .= $fields;
              }
              if ($joins) {
                  $alljoins .= ' ' . $joins;
              }
              if ($params) {
                  $allparams += $params;
              }
          }
  
          if ($allfields === '') {
              return array('', array());
          }
  
          return array("SELECT $allfields FROM $alljoins WHERE quiz.id = :quizid", $allparams);
      }
code: protected static function get_load_sql($quizid, $rules, $basefields) {
          $allfields = $basefields;
          $alljoins = '{quiz} quiz';
          $allparams = array('quizid' => $quizid);
  
          foreach ($rules as $rule) {
              list($fields, $joins, $params) = $rule::get_settings_sql($quizid);
              if ($fields) {
                  if ($allfields) {
                      $allfields .= ', ';
                  }
                  $allfields .= $fields;
              }
              if ($joins) {
                  $alljoins .= ' ' . $joins;
              }
              if ($params) {
                  $allparams += $params;
              }
          }
  
          if ($allfields === '') {
              return array('', array());
          }
  
          return array("SELECT $allfields FROM $alljoins WHERE quiz.id = :quizid", $allparams);
      }
code_tokens: protected static function get_load_sql ( $ quizid , $ rules , $ basefields ) { $ allfields = $ basefields ; $ alljoins = '{quiz} quiz' ; $ allparams = array ( 'quizid' => $ quizid ) ; foreach ( $ rules as $ rule ) { list ( $ fields , $ joins , $ params ) = $ rule :: get_settings_sql ( $ quizid ) ; if ( $ fields ) { if ( $ allfields ) { $ allfields .= ', ' ; } $ allfields .= $ fields ; } if ( $ joins ) { $ alljoins .= ' ' . $ joins ; } if ( $ params ) { $ allparams += $ params ; } } if ( $ allfields === '' ) { return array ( '' , array ( ) ) ; } return array ( "SELECT $allfields FROM $alljoins WHERE quiz.id = :quizid" , $ allparams ) ; }
docstring: Build the SQL for loading all the access settings in one go.
  @param int $quizid the quiz id.
  @param string $basefields initial part of the select list.
  @return array with two elements, the sql and the placeholder values.
  If $basefields is '' then you must allow for the possibility that
  there is no data to load, in which case this method returns $sql = ''.
docstring_tokens: Build the SQL for loading all the access settings in one go .