Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F112005520
ReleephProjectQuery.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, May 6, 16:47
Size
1 KB
Mime Type
text/x-php
Expires
Thu, May 8, 16:47 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
25993955
Attached To
rPH Phabricator
ReleephProjectQuery.php
View Options
<?php
final
class
ReleephProjectQuery
extends
PhabricatorCursorPagedPolicyAwareQuery
{
private
$active
;
private
$order
=
'order-id'
;
const
ORDER_ID
=
'order-id'
;
const
ORDER_NAME
=
'order-name'
;
public
function
withActive
(
$active
)
{
$this
->
active
=
$active
;
return
$this
;
}
public
function
setOrder
(
$order
)
{
$this
->
order
=
$order
;
return
$this
;
}
public
function
loadPage
()
{
$table
=
new
ReleephProject
();
$conn_r
=
$table
->
establishConnection
(
'r'
);
$rows
=
queryfx_all
(
$conn_r
,
'SELECT * FROM %T %Q %Q %Q'
,
$table
->
getTableName
(),
$this
->
buildWhereClause
(
$conn_r
),
$this
->
buildOrderClause
(
$conn_r
),
$this
->
buildLimitClause
(
$conn_r
));
return
$table
->
loadAllFromArray
(
$rows
);
}
private
function
buildWhereClause
(
AphrontDatabaseConnection
$conn_r
)
{
$where
=
array
();
if
(
$this
->
active
!==
null
)
{
$where
[]
=
qsprintf
(
$conn_r
,
'isActive = %d'
,
$this
->
active
);
}
$where
[]
=
$this
->
buildPagingClause
(
$conn_r
);
return
$this
->
formatWhereClause
(
$where
);
}
protected
function
getReversePaging
()
{
switch
(
$this
->
order
)
{
case
self
::
ORDER_NAME
:
return
true
;
}
return
parent
::
getReversePaging
();
}
protected
function
getPagingValue
(
$result
)
{
switch
(
$this
->
order
)
{
case
self
::
ORDER_NAME
:
return
$result
->
getName
();
}
return
parent
::
getPagingValue
();
}
protected
function
getPagingColumn
()
{
switch
(
$this
->
order
)
{
case
self
::
ORDER_NAME
:
return
'name'
;
case
self
::
ORDER_ID
:
return
parent
::
getPagingColumn
();
default
:
throw
new
Exception
(
"Uknown order '{$this->order}'!"
);
}
}
}
Event Timeline
Log In to Comment