original_string: private function get_condition_sql($field, $field2 = null, $istext = false) {
          global $DB;
          if (is_null($field2)) {
              $field2 = $field;
          }
  
          $params = array();
          switch($this->operator) {
              case self::OP_CONTAINS:
                  $sql = $DB->sql_like($field, self::unique_sql_parameter(
                          $params, '%' . $this->value . '%'));
                  break;
              case self::OP_DOES_NOT_CONTAIN:
                  if (empty($this->value)) {
                      // The 'does not contain nothing' expression matches everyone.
                      return null;
                  }
                  $sql = $DB->sql_like($field, self::unique_sql_parameter(
                          $params, '%' . $this->value . '%'), true, true, true);
                  break;
              case self::OP_IS_EQUAL_TO:
                  if ($istext) {
                      $sql = $DB->sql_compare_text($field) . ' = ' . $DB->sql_compare_text(
                              self::unique_sql_parameter($params, $this->value));
                  } else {
                      $sql = $field . ' = ' . self::unique_sql_parameter(
                              $params, $this->value);
                  }
                  break;
              case self::OP_STARTS_WITH:
                  $sql = $DB->sql_like($field, self::unique_sql_parameter(
                          $params, $this->value . '%'));
                  break;
              case self::OP_ENDS_WITH:
                  $sql = $DB->sql_like($field, self::unique_sql_parameter(
                          $params, '%' . $this->value));
                  break;
              case self::OP_IS_EMPTY:
                  // Mimic PHP empty() behaviour for strings, '0' or ''.
                  $emptystring = self::unique_sql_parameter($params, '');
                  if ($istext) {
                      $sql = '(' . $DB->sql_compare_text($field) . " IN ('0', $emptystring) OR $field2 IS NULL)";
                  } else {
                      $sql = '(' . $field . " IN ('0', $emptystring) OR $field2 IS NULL)";
                  }
                  break;
              case self::OP_IS_NOT_EMPTY:
                  $emptystring = self::unique_sql_parameter($params, '');
                  if ($istext) {
                      $sql = '(' . $DB->sql_compare_text($field) . " NOT IN ('0', $emptystring) AND $field2 IS NOT NULL)";
                  } else {
                      $sql = '(' . $field . " NOT IN ('0', $emptystring) AND $field2 IS NOT NULL)";
                  }
                  break;
          }
          return array($sql, $params);
      }
code: private function get_condition_sql($field, $field2 = null, $istext = false) {
          global $DB;
          if (is_null($field2)) {
              $field2 = $field;
          }
  
          $params = array();
          switch($this->operator) {
              case self::OP_CONTAINS:
                  $sql = $DB->sql_like($field, self::unique_sql_parameter(
                          $params, '%' . $this->value . '%'));
                  break;
              case self::OP_DOES_NOT_CONTAIN:
                  if (empty($this->value)) {
                      // The 'does not contain nothing' expression matches everyone.
                      return null;
                  }
                  $sql = $DB->sql_like($field, self::unique_sql_parameter(
                          $params, '%' . $this->value . '%'), true, true, true);
                  break;
              case self::OP_IS_EQUAL_TO:
                  if ($istext) {
                      $sql = $DB->sql_compare_text($field) . ' = ' . $DB->sql_compare_text(
                              self::unique_sql_parameter($params, $this->value));
                  } else {
                      $sql = $field . ' = ' . self::unique_sql_parameter(
                              $params, $this->value);
                  }
                  break;
              case self::OP_STARTS_WITH:
                  $sql = $DB->sql_like($field, self::unique_sql_parameter(
                          $params, $this->value . '%'));
                  break;
              case self::OP_ENDS_WITH:
                  $sql = $DB->sql_like($field, self::unique_sql_parameter(
                          $params, '%' . $this->value));
                  break;
              case self::OP_IS_EMPTY:
                  // Mimic PHP empty() behaviour for strings, '0' or ''.
                  $emptystring = self::unique_sql_parameter($params, '');
                  if ($istext) {
                      $sql = '(' . $DB->sql_compare_text($field) . " IN ('0', $emptystring) OR $field2 IS NULL)";
                  } else {
                      $sql = '(' . $field . " IN ('0', $emptystring) OR $field2 IS NULL)";
                  }
                  break;
              case self::OP_IS_NOT_EMPTY:
                  $emptystring = self::unique_sql_parameter($params, '');
                  if ($istext) {
                      $sql = '(' . $DB->sql_compare_text($field) . " NOT IN ('0', $emptystring) AND $field2 IS NOT NULL)";
                  } else {
                      $sql = '(' . $field . " NOT IN ('0', $emptystring) AND $field2 IS NOT NULL)";
                  }
                  break;
          }
          return array($sql, $params);
      }
code_tokens: private function get_condition_sql ( $ field , $ field2 = null , $ istext = false ) { global $ DB ; if ( is_null ( $ field2 ) ) { $ field2 = $ field ; } $ params = array ( ) ; switch ( $ this -> operator ) { case self :: OP_CONTAINS : $ sql = $ DB -> sql_like ( $ field , self :: unique_sql_parameter ( $ params , '%' . $ this -> value . '%' ) ) ; break ; case self :: OP_DOES_NOT_CONTAIN : if ( empty ( $ this -> value ) ) { // The 'does not contain nothing' expression matches everyone. return null ; } $ sql = $ DB -> sql_like ( $ field , self :: unique_sql_parameter ( $ params , '%' . $ this -> value . '%' ) , true , true , true ) ; break ; case self :: OP_IS_EQUAL_TO : if ( $ istext ) { $ sql = $ DB -> sql_compare_text ( $ field ) . ' = ' . $ DB -> sql_compare_text ( self :: unique_sql_parameter ( $ params , $ this -> value ) ) ; } else { $ sql = $ field . ' = ' . self :: unique_sql_parameter ( $ params , $ this -> value ) ; } break ; case self :: OP_STARTS_WITH : $ sql = $ DB -> sql_like ( $ field , self :: unique_sql_parameter ( $ params , $ this -> value . '%' ) ) ; break ; case self :: OP_ENDS_WITH : $ sql = $ DB -> sql_like ( $ field , self :: unique_sql_parameter ( $ params , '%' . $ this -> value ) ) ; break ; case self :: OP_IS_EMPTY : // Mimic PHP empty() behaviour for strings, '0' or ''. $ emptystring = self :: unique_sql_parameter ( $ params , '' ) ; if ( $ istext ) { $ sql = '(' . $ DB -> sql_compare_text ( $ field ) . " IN ('0', $emptystring) OR $field2 IS NULL)" ; } else { $ sql = '(' . $ field . " IN ('0', $emptystring) OR $field2 IS NULL)" ; } break ; case self :: OP_IS_NOT_EMPTY : $ emptystring = self :: unique_sql_parameter ( $ params , '' ) ; if ( $ istext ) { $ sql = '(' . $ DB -> sql_compare_text ( $ field ) . " NOT IN ('0', $emptystring) AND $field2 IS NOT NULL)" ; } else { $ sql = '(' . $ field . " NOT IN ('0', $emptystring) AND $field2 IS NOT NULL)" ; } break ; } return array ( $ sql , $ params ) ; }
docstring: Gets SQL to match a field against this condition. The second copy of the
  field is in case you're using variables for the field so that it needs
  to be two different ones.
  
  @param string $field Field name
  @param string $field2 Second copy of field name (default same).
  @param boolean $istext Any of the fields correspond to a TEXT column in database (true) or not (false).
  @return array Array of SQL and parameters
docstring_tokens: Gets SQL to match a field against this condition . The second copy of the field is in case you re using variables for the field so that it needs to be two different ones .