Beispiel #1
0
 /**
  * Apply the added and replacement parts to the parts of the base query.
  * 
  * @return array
  */
 public function getParts()
 {
     if (!isset($this->cachedParts)) {
         $parts = $this->getBaseParts();
         if (empty($this->partsAdd) && empty($this->partsReplace)) {
             return $parts;
         }
         if (!empty($this->partsReplace)) {
             $parts = array_merge($parts, $this->partsReplace);
         }
         if (!empty($this->partsAdd)) {
             $parts = QuerySplitter::addParts($parts, $this->partsAdd);
         }
         if (key($parts) == 'select' && empty($parts['columns'])) {
             $parts['columns'] = '*';
         }
         if (isset($parts['on duplicate key update']) && trim($parts['on duplicate key update']) === '1') {
             $columns = QuerySplitter::splitColumns($parts);
             foreach ($columns as &$column) {
                 $column = "{$column} = VALUES({$column})";
             }
             $parts['on duplicate key update'] = join(', ', $columns);
         }
         $this->cachedParts =& $parts;
     }
     return empty($this->subqueries) ? $this->cachedParts : QuerySplitter::injectSubsets(array($this->cachedParts) + $this->subqueries);
 }