Code of Civil Procedure § 1997
CHAPTER 2. Means of Production
If the witness be imprisoned in a jail in the county where the action or proceeding is pending, his production may be required. In all other cases his examination, when allowed, must be taken upon deposition.