To add some visual information to my post above:
On the left is ritalinic acid. Note the carbon connected to both an OH group and a double-bonded oxygen? That's a carboxyl group. If you replace the hydrogen on the OH with an alkyl, you get an ester: in this case the methyl ester, methylphenidate.
Such esters are typically formed via a condensation reaction, i.e. by combining a carboxylic acid and an alcohol and subtracting H2O. Ritalinic acid and methyl alcohol both bring an OH group to the reaction. Subtract 2 H's and 1 O, and what we get is a methyl group connected to an oxygen atom.
Likewise, on the left we have the carboxylic acid form of cocaine, benzoylecgonine. To the right, we have its ethyl ester, cocaethylene. It is formed via a process called transesterification, i.e. when the methyl group on cocaine is switched out with an ethyl group by adding the corresponding alcohol (i.e. ethanol).
Here we have amphetamine:
No COOH group, no transesterification.
Edit: And yes, as sekio said, only a fraction of the methylphenidate in your body is actually transesterified, and apparently you're primarily transesterifying the less active/inactive isomers. Also, the effects of ethylphenidate aren't all that different from methylphenidate to begin with.
Cocaine is a slightly different matter, because IIRC the percentage of cocaine that's getting transesterified is higher than for methylphenidate, plus cocaethylene has a significantly longer half-life than plain cocaine.