/** * Merge to * @param QueryBuilder $qb */ public function merge(QueryBuilder $qb) { $parts = $qb->getSQLParts(); //print_r($parts);exit; /*'select' => array(), 'from' => array(), 'join' => array(), 'set' => array(), 'where' => null, 'groupBy' => array(), 'having' => null, 'orderBy' => array(), 'limit' => null*/ foreach ($parts['select'] as $select) { $this->add("select", $select, true); } foreach ($parts['from'] as $from) { $this->add("from", $from, true); } foreach ($parts['join'] as $join) { $this->add("join", $join, true); } foreach ($parts['set'] as $set) { $this->add("set", $set, true); } $this->andWhere($parts['where']); foreach ($parts['groupBy'] as $groupBy) { $this->add("groupBy", $groupBy, true); } if (isset($parts['having']) and is_array($parts['having'])) { foreach ($parts['having'] as $having) { $this->add("having", $having, true); } } foreach ($parts['orderBy'] as $orderBy) { $this->add("orderBy", $orderBy, true); } $this->add("limit", $parts['limit'], false); }