1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
-
-
- namespace Doctrine\ORM\Query\Expr;
-
-
- class Composite extends Base
- {
- public function __toString()
- {
- if ($this->count() === 1) {
- return (string) $this->_parts[0];
- }
-
- $components = array();
-
- foreach ($this->_parts as $part) {
- $components[] = $this->processQueryPart($part);
- }
-
- return implode($this->_separator, $components);
- }
-
-
- private function processQueryPart($part)
- {
- $queryPart = (string) $part;
-
- if (is_object($part) && $part instanceof self && $part->count() > 1) {
- return $this->_preSeparator . $queryPart . $this->_postSeparator;
- }
-
-
- if (mb_stripos($queryPart, ' OR ') !== false || mb_stripos($queryPart, ' AND ') !== false) {
- return $this->_preSeparator . $queryPart . $this->_postSeparator;
- }
-
- return $queryPart;
- }
- }
|