Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F78368524
PhabricatorQuery.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Tue, Aug 20, 07:58
Size
2 KB
Mime Type
text/x-php
Expires
Thu, Aug 22, 07:58 (2 d)
Engine
blob
Format
Raw Data
Handle
20034399
Attached To
rPH Phabricator
PhabricatorQuery.php
View Options
<?php
/**
* @task format Formatting Query Clauses
*/
abstract
class
PhabricatorQuery
extends
Phobject
{
abstract
public
function
execute
();
/* -( Formatting Query Clauses )------------------------------------------- */
/**
* @task format
*/
protected
function
formatWhereClause
(
array
$parts
)
{
$parts
=
$this
->
flattenSubclause
(
$parts
);
if
(!
$parts
)
{
return
''
;
}
return
'WHERE '
.
$this
->
formatWhereSubclause
(
$parts
);
}
/**
* @task format
*/
protected
function
formatWhereSubclause
(
array
$parts
)
{
$parts
=
$this
->
flattenSubclause
(
$parts
);
if
(!
$parts
)
{
return
null
;
}
return
'('
.
implode
(
') AND ('
,
$parts
).
')'
;
}
/**
* @task format
*/
protected
function
formatSelectClause
(
array
$parts
)
{
$parts
=
$this
->
flattenSubclause
(
$parts
);
if
(!
$parts
)
{
throw
new
Exception
(
pht
(
'Can not build empty select clause!'
));
}
return
'SELECT '
.
$this
->
formatSelectSubclause
(
$parts
);
}
/**
* @task format
*/
protected
function
formatSelectSubclause
(
array
$parts
)
{
$parts
=
$this
->
flattenSubclause
(
$parts
);
if
(!
$parts
)
{
return
null
;
}
return
implode
(
', '
,
$parts
);
}
/**
* @task format
*/
protected
function
formatJoinClause
(
array
$parts
)
{
$parts
=
$this
->
flattenSubclause
(
$parts
);
if
(!
$parts
)
{
return
''
;
}
return
implode
(
' '
,
$parts
);
}
/**
* @task format
*/
protected
function
formatHavingClause
(
array
$parts
)
{
$parts
=
$this
->
flattenSubclause
(
$parts
);
if
(!
$parts
)
{
return
''
;
}
return
'HAVING '
.
$this
->
formatHavingSubclause
(
$parts
);
}
/**
* @task format
*/
protected
function
formatHavingSubclause
(
array
$parts
)
{
$parts
=
$this
->
flattenSubclause
(
$parts
);
if
(!
$parts
)
{
return
null
;
}
return
'('
.
implode
(
') AND ('
,
$parts
).
')'
;
}
/**
* @task format
*/
private
function
flattenSubclause
(
array
$parts
)
{
$result
=
array
();
foreach
(
$parts
as
$part
)
{
if
(
is_array
(
$part
))
{
foreach
(
$this
->
flattenSubclause
(
$part
)
as
$subpart
)
{
$result
[]
=
$subpart
;
}
}
else
if
(
strlen
(
$part
))
{
$result
[]
=
$part
;
}
}
return
$result
;
}
}
Event Timeline
Log In to Comment