original_string: public static function selectOneSQL(Connection $connection, $sql, array $parameters = [], array $field_mapping = [])
      {
          $stmt = $connection->prepare($sql);
          $stmt->execute($parameters);
          $result = $stmt->fetch();
          if ($result) {
              foreach ($field_mapping as $result_column => $entity_field) {
                  if (!isset($result[$result_column])) {
                      continue;
                  }
                  $result[$entity_field] = $result[$result_column];
                  unset($result[$result_column]);
              }
  
              foreach (static::$types as $column => $type) {
                  if (isset($result[$column])) {
                      $result[$column] = $connection->convertToPHPValue($result[$column], $type);
                  }
              }
              $entity = new static($connection, $result);
  
              return $entity->setStored();
          }
  
          return null;
      }
code: public static function selectOneSQL(Connection $connection, $sql, array $parameters = [], array $field_mapping = [])
      {
          $stmt = $connection->prepare($sql);
          $stmt->execute($parameters);
          $result = $stmt->fetch();
          if ($result) {
              foreach ($field_mapping as $result_column => $entity_field) {
                  if (!isset($result[$result_column])) {
                      continue;
                  }
                  $result[$entity_field] = $result[$result_column];
                  unset($result[$result_column]);
              }
  
              foreach (static::$types as $column => $type) {
                  if (isset($result[$column])) {
                      $result[$column] = $connection->convertToPHPValue($result[$column], $type);
                  }
              }
              $entity = new static($connection, $result);
  
              return $entity->setStored();
          }
  
          return null;
      }
code_tokens: public static function selectOneSQL ( Connection $ connection , $ sql , array $ parameters = [ ] , array $ field_mapping = [ ] ) { $ stmt = $ connection -> prepare ( $ sql ) ; $ stmt -> execute ( $ parameters ) ; $ result = $ stmt -> fetch ( ) ; if ( $ result ) { foreach ( $ field_mapping as $ result_column => $ entity_field ) { if ( ! isset ( $ result [ $ result_column ] ) ) { continue ; } $ result [ $ entity_field ] = $ result [ $ result_column ] ; unset ( $ result [ $ result_column ] ) ; } foreach ( static :: $ types as $ column => $ type ) { if ( isset ( $ result [ $ column ] ) ) { $ result [ $ column ] = $ connection -> convertToPHPValue ( $ result [ $ column ] , $ type ) ; } } $ entity = new static ( $ connection , $ result ) ; return $ entity -> setStored ( ) ; } return null ; }
docstring: Select a single entity matching an SQL query. If more than one
  row is matched by the query, only the first entity will be
  returned.
  
  @param Connection $connection    A connection instance
  @param string     $sql           The SQL query
  @param array      $parameters    Any bound parameters required for the query
  @param array      $field_mapping An array of result columns => entity fields
  
  @return Entity|null The selected Entity, or null if no entity was found
docstring_tokens: Select a single entity matching an SQL query . If more than one row is matched by the query only the first entity will be returned .