. */ Doctrine::autoload('Doctrine_Query_Part'); /** * Doctrine_Query_Groupby * * @package Doctrine * @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @category Object Relational Mapping * @link www.phpdoctrine.com * @since 1.0 * @version $Revision$ * @author Konsta Vesterinen */ class Doctrine_Query_Groupby extends Doctrine_Query_Part { /** * DQL GROUP BY PARSER * parses the group by part of the query string * @param string $str * @return void */ public function parse($str, $append = false) { $r = array(); foreach (explode(',', $str) as $reference) { $reference = trim($reference); $e = explode('.', $reference); $field = array_pop($e); $ref = implode('.', $e); $this->query->load($ref); $r[] = $this->query->getTableAlias($ref) . '.' . $field; } if ($append) { $this->query->addQueryPart('groupby', implode(', ', $r)); } else { $this->query->setQueryPart('groupby', implode(', ', $r)); } return $this->query; } }