4 * @task format Formatting Query Clauses
6 abstract class PhabricatorQuery
extends Phobject
{
9 abstract public function execute();
12 /* -( Formatting Query Clauses )------------------------------------------- */
18 protected function formatWhereClause(
19 AphrontDatabaseConnection
$conn,
22 $parts = $this->flattenSubclause($parts);
24 return qsprintf($conn, '');
27 return qsprintf($conn, 'WHERE %LA', $parts);
35 protected function formatSelectClause(
36 AphrontDatabaseConnection
$conn,
39 $parts = $this->flattenSubclause($parts);
41 throw new Exception(pht('Can not build empty SELECT clause!'));
44 return qsprintf($conn, 'SELECT %LQ', $parts);
51 protected function formatJoinClause(
52 AphrontDatabaseConnection
$conn,
55 $parts = $this->flattenSubclause($parts);
57 return qsprintf($conn, '');
60 return qsprintf($conn, '%LJ', $parts);
67 protected function formatHavingClause(
68 AphrontDatabaseConnection
$conn,
71 $parts = $this->flattenSubclause($parts);
73 return qsprintf($conn, '');
76 return qsprintf($conn, 'HAVING %LA', $parts);
83 private function flattenSubclause(array $parts) {
85 foreach ($parts as $part) {
86 if (is_array($part)) {
87 foreach ($this->flattenSubclause($part) as $subpart) {
90 } else if (($part !== null) && strlen($part)) {