With digital images and computer processing, there is now another option called "Focus Stacking". This involves taking a series of images, with the camera focused at different distances from the camera. Each image will then contain a version of the scene, with a part at a different depth in sharp focus. These images are then submitted to a computer program that isolates the part of each image that is in sharp focus and then merges these together into a single image which is all (or mostly) in sharp focus. There are a number of such programs available, from free to commercially sold.
Here is a small experiment that I did with a free program called CombineZP.
First I took a series of images at different focus depths. Below are five images out of that series.