_stringPrimary; } public function isLeading() { return $this->_leading; } public function setLeading($bool) { $this->_leading = $bool; } public function isTrailing() { return $this->_trailing; } public function setTrailing($bool) { $this->_trailing = $bool; } public function isBoth() { return $this->_both; } public function setBoth($bool) { $this->_both = $bool; } public function getTrimChar() { return $this->_trimChar; } public function setTrimChar($trimChar) { $this->_trimChar = $trimChar; } /** * @override */ public function getSql(\Doctrine\ORM\Query\SqlWalker $sqlWalker) { $sql = 'TRIM('; if ($this->_leading) $sql .= 'LEADING '; else if ($this->_trailing) $sql .= 'TRAILING '; else if ($this->_both) $sql .= 'BOTH '; if ($this->_trimChar) $sql .= $sqlWalker->getConnection()->quote($this->_trimChar) . ' '; $sql .= 'FROM ' . $sqlWalker->walkStringPrimary($this->_stringPrimary); $sql .= ')'; return $sql; } /** * @override */ public function parse(\Doctrine\ORM\Query\Parser $parser) { $lexer = $parser->getLexer(); $parser->match($lexer->lookahead['value']); $parser->match('('); if (strcasecmp('leading', $lexer->lookahead['value']) === 0) { $parser->match($lexer->lookahead['value']); $this->_leading = true; } else if (strcasecmp('trailing', $lexer->lookahead['value']) === 0) { $parser->match($lexer->lookahead['value']); $this->_trailing = true; } else if (strcasecmp('both', $lexer->lookahead['value']) === 0) { $parser->match($lexer->lookahead['value']); $this->_both = true; } if ($lexer->isNextToken(Lexer::T_STRING)) { $parser->match(Lexer::T_STRING); $this->_trimChar = $lexer->token['value']; } if ($this->_leading || $this->_trailing || $this->_both || $this->_trimChar) { $parser->match(Lexer::T_FROM); } $this->_stringPrimary = $parser->StringPrimary(); $parser->match(')'); } }