THE BASIC TRICK
Take one Cleric, with the Magic domain.
Take the Customize Domain feat, from Dragon 325. For each of your spell slots, you may not select any spell, as long as it is one level lower than normal, for example Fireball in your 4th level spell slot.
Use one of any number of tricks to get Psychic Reformation without the XP penalty.
You may now cast any spell up to 8th level in existence, should the need arise. Get Psychic Reformation as a swift or free action, and Domain Spontaneity, and you can even cast any spell you need spontaneously. Combine with Anyspell shenanigans for some nice Cleric flexibility.
THE ADVANCED TRICK
Customize Domain lets you replace the spells in the Evil domain with any [Evil] spell, the spells in the Earth domain with any [Earth] spell, and so on. The description of the feat states that 'certain spells gain descriptors depending on how they're cast; you can choose such a spell as a spell with the descriptor you require so long as you only cast the spell in such a manner as to give it that descriptor.' If you can find a way to give all your spells a descriptor such as Evil, or Earth, you can select any spell you want in the slot, meaning you can now cast any spell in existence should the need arise.