Ben Long explains how a digital camera sensor actually works. You should read the whole article — it’s brief but clear and comprehensive.
… the surface of the chip is covered with a grid of electrodes called photosites. Each photosite corresponds to a pixel in your final image. … when light strikes a particular photosite, the metal in that site releases some of its electrons … these released electrons get trapped, effectively piling up inside a little well. After the exposure, your camera simply has to measure the voltage at each site to determine how many electrons have heaped up there, and thus how much light hit that particular spot.
He also clears up why purple fringing occurs:
a photosite collects so much light that it overflows into the adjacent photosites. [Via: PhotographyBLOG]