Ticket #1195: RawSql_p1.patch
| File RawSql_p1.patch, 1.4 KB (added by stefan, 6 months ago) |
|---|
-
RawSql.php
72 72 $this->_parseSelectFields($queryPart); 73 73 return $this; 74 74 } 75 if ( ! isset($this-> parts[$queryPartName])) {75 if ( ! isset($this->_sqlParts[$queryPartName])) { 76 76 $this->_sqlParts[$queryPartName] = array(); 77 77 } 78 78 … … 220 220 } 221 221 } 222 222 223 $q = 'SELECT '; 224 if($this->_sqlParts['distinct'] == true) $q .= 'DISTINCT '; 225 223 226 // first add the fields of the root component 224 227 reset($this->_queryComponents); 225 228 $componentAlias = key($this->_queryComponents); 226 227 $q = 'SELECT ' . implode(', ', $select[$componentAlias]); 229 $q .= implode(', ', $select[$componentAlias]); 228 230 unset($select[$componentAlias]); 229 231 230 232 foreach ($select as $component => $fields) { … … 237 239 if ( ! empty($string)) { 238 240 $this->_sqlParts['where'][] = $string; 239 241 } 240 $copy = $this->_sqlParts;241 unset($copy['select']);242 242 243 243 $q .= ( ! empty($this->_sqlParts['from']))? ' FROM ' . implode(' ', $this->_sqlParts['from']) : ''; 244 244 $q .= ( ! empty($this->_sqlParts['where']))? ' WHERE ' . implode(' AND ', $this->_sqlParts['where']) : '';