/**
  * Get SQL query part
  *
  * @param \Doctrine\ORM\Query\SqlWalker $sqlWalker SQL walker
  *
  * @return string
  */
 public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker)
 {
     $sql = '';
     $phrase = trim($this->relevanceSearchWords->dispatch($sqlWalker), '\'');
     $words = explode(' ', $phrase);
     $titleFactor = round(20 / count($words), 2);
     $textFactor = round(10 / count($words), 2);
     $sql .= '(';
     $sql .= sprintf(' IF (%s LIKE \'%%%s%%\', 60, 0)', $this->relevanceTitleField->dispatch($sqlWalker), $phrase);
     $sql .= '+';
     $sql .= sprintf(' IF (%s LIKE \'%%%s%%\', 10, 0)', $this->relevanceTextField->dispatch($sqlWalker), $phrase);
     foreach ($words as $word) {
         $sql .= '+';
         $sql .= sprintf(' IF (%s LIKE \'%%%s%%\', %s, 0)', $this->relevanceTitleField->dispatch($sqlWalker), $word, $titleFactor);
         $sql .= '+';
         $sql .= sprintf(' IF (%s LIKE \'%%%s%%\', %s, 0)', $this->relevanceTextField->dispatch($sqlWalker), $word, $textFactor);
     }
     $sql .= ')';
     return $sql;
 }
Beispiel #2
0
 public function getSql(SqlWalker $walker)
 {
     return sprintf('CAST(%s AS %s)', $this->field->dispatch($walker), $this->type);
 }
 /**
  * {@inheritdoc}
  */
 public function getSql(SqlWalker $sqlWalker)
 {
     $this->loadConversionHints($sqlWalker);
     return $this->nativePlatform->getFieldColumn($this->fieldName, $this->strategy, $this->columnExpression->dispatch($sqlWalker));
 }
 public function getSql(SqlWalker $sqlWalker)
 {
     return $this->field->dispatch($sqlWalker);
 }