Implement saving queries.

Summary: Enable saved query objects to actually be saved to the database.

Test Plan: Insert a call to save() and check that the query is written correctly.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, Korvin, AnhNhan

Maniphest Tasks: T2625

Differential Revision: https://secure.phabricator.com/D5775

Conflicts:

	src/infrastructure/storage/patch/PhabricatorBuiltinPatchList.php