Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F2894702
PhabricatorDiagramVersionQuery.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Award Token
Flag For Later
Advanced/Developer...
View Handle
View Hovercard
Size
2 KB
Referenced Files
None
Subscribers
None
PhabricatorDiagramVersionQuery.php
View Options
<?php
final
class
PhabricatorDiagramVersionQuery
extends
PhabricatorCursorPagedPolicyAwareQuery
{
protected
$diagramIDs
;
protected
$modifiedAfter
;
protected
$modifiedBefore
;
public
function
withDiagramIDs
(
array
$diagram_ids
)
{
$this
->
diagramIDs
=
$diagram_ids
;
return
$this
;
}
public
function
withIDs
(
array
$diagram_ids
)
{
return
$this
->
withDiagramIDs
(
$diagram_ids
)
;
}
public
function
withModifiedAfter
(
$datetime
)
{
$this
->
modifiedAfter
=
$datetime
;
return
$this
;
}
public
function
withModifiedBefore
(
$datetime
)
{
$this
->
modifiedBefore
=
$datetime
;
return
$this
;
}
protected
function
loadPage
(
)
{
$table
=
new
DiagramVersion
(
)
;
$conn_r
=
$table
->
establishConnection
(
'r'
)
;
// we return a DiagramVersion object which has a different id
// than the one we mention in the Remarkup code.
// E.g. {DIAG1} may point to the 2nd version of the object.
// Diagram's id is 1, but DiagramVersion's id is 2.
// Because of this we abuse the id in the resultset a little bit
$data
=
queryfx_all
(
$conn_r
,
'SELECT *
FROM (
SELECT result.diagramID AS id, /* abuse */
result.diagramID,
result.version,
result.phid,
result.authorPHID,
result.dateCreated,
result.dateModified,
result.byteSize,
result.data,
result.viewPolicy,
result.editPolicy
FROM (
SELECT data.*
FROM %T data
INNER JOIN (
SELECT MAX(id) AS id,
diagramid
FROM %T
GROUP BY diagramid HAVING MAX(id)
) filter
ON data.id = filter.id
) result
) r %Q %Q %Q'
,
$table
->
getTableName
(
)
,
$table
->
getTableName
(
)
,
$this
->
buildWhereClause
(
$conn_r
)
,
$this
->
buildOrderClause
(
$conn_r
)
,
$this
->
buildLimitClause
(
$conn_r
)
)
;
return
$table
->
loadAllFromArray
(
$data
)
;
}
protected
function
buildWhereClause
(
AphrontDatabaseConnection
$conn_r
)
{
$where
=
array
(
)
;
$where
[
]
=
$this
->
buildPagingClause
(
$conn_r
)
;
if
(
$this
->
diagramIDs
!==
null
)
{
$where
[
]
=
qsprintf
(
$conn_r
,
'diagramID IN (%Ld)'
,
$this
->
diagramIDs
)
;
}
if
(
$this
->
modifiedAfter
!==
null
)
{
$where
[
]
=
qsprintf
(
$conn_r
,
'dateModified >= %d'
,
$this
->
modifiedAfter
)
;
}
if
(
$this
->
modifiedBefore
!==
null
)
{
$where
[
]
=
qsprintf
(
$conn_r
,
'dateModified <= %d'
,
$this
->
modifiedBefore
)
;
}
return
$this
->
formatWhereClause
(
$conn_r
,
$where
)
;
}
public
function
getQueryApplicationClass
(
)
{
return
DiagramApplication
::
class
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sun, Jan 19, 20:18 (1 w, 5 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1128382
Default Alt Text
PhabricatorDiagramVersionQuery.php (2 KB)
Attached To
Mode
R5 Diagrams
Attached
Detach File
Event Timeline
Log In to Comment