123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869 |
- <?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 (stripos($queryPart, ' OR ') !== false || stripos($queryPart, ' AND ') !== false) {
- return $this->_preSeparator . $queryPart . $this->_postSeparator;
- }
-
- return $queryPart;
- }
- }
|