Changeset View
Changeset View
Standalone View
Standalone View
src/applications/conpherence/query/ConpherenceFulltextQuery.php
Show All 32 Lines | $rows = queryfx_all( | ||||
$table->getTableName(), | $table->getTableName(), | ||||
$this->buildWhereClause($conn_r), | $this->buildWhereClause($conn_r), | ||||
$this->buildOrderByClause($conn_r), | $this->buildOrderByClause($conn_r), | ||||
$this->buildLimitClause($conn_r)); | $this->buildLimitClause($conn_r)); | ||||
return $rows; | return $rows; | ||||
} | } | ||||
protected function buildWhereClause(AphrontDatabaseConnection $conn_r) { | protected function buildWhereClause(AphrontDatabaseConnection $conn) { | ||||
$where = array(); | $where = array(); | ||||
if ($this->threadPHIDs !== null) { | if ($this->threadPHIDs !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn_r, | $conn, | ||||
'i.threadPHID IN (%Ls)', | 'i.threadPHID IN (%Ls)', | ||||
$this->threadPHIDs); | $this->threadPHIDs); | ||||
} | } | ||||
if ($this->previousTransactionPHIDs !== null) { | if ($this->previousTransactionPHIDs !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn_r, | $conn, | ||||
'i.previousTransactionPHID IN (%Ls)', | 'i.previousTransactionPHID IN (%Ls)', | ||||
$this->previousTransactionPHIDs); | $this->previousTransactionPHIDs); | ||||
} | } | ||||
if (strlen($this->fulltext)) { | if (strlen($this->fulltext)) { | ||||
$compiler = PhabricatorSearchDocument::newQueryCompiler(); | $compiler = PhabricatorSearchDocument::newQueryCompiler(); | ||||
$tokens = $compiler->newTokens($this->fulltext); | $tokens = $compiler->newTokens($this->fulltext); | ||||
$compiled_query = $compiler->compileQuery($tokens); | $compiled_query = $compiler->compileQuery($tokens); | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn_r, | $conn, | ||||
'MATCH(i.corpus) AGAINST (%s IN BOOLEAN MODE)', | 'MATCH(i.corpus) AGAINST (%s IN BOOLEAN MODE)', | ||||
$compiled_query); | $compiled_query); | ||||
} | } | ||||
return $this->formatWhereClause($where); | return $this->formatWhereClause($conn, $where); | ||||
} | } | ||||
private function buildOrderByClause(AphrontDatabaseConnection $conn_r) { | private function buildOrderByClause(AphrontDatabaseConnection $conn_r) { | ||||
if (strlen($this->fulltext)) { | if (strlen($this->fulltext)) { | ||||
return qsprintf( | return qsprintf( | ||||
$conn_r, | $conn_r, | ||||
'ORDER BY MATCH(i.corpus) AGAINST (%s IN BOOLEAN MODE) DESC', | 'ORDER BY MATCH(i.corpus) AGAINST (%s IN BOOLEAN MODE) DESC', | ||||
$this->fulltext); | $this->fulltext); | ||||
} else { | } else { | ||||
return qsprintf( | return qsprintf( | ||||
$conn_r, | $conn_r, | ||||
'ORDER BY id DESC'); | 'ORDER BY id DESC'); | ||||
} | } | ||||
} | } | ||||
} | } |