. */ Doctrine::autoload("Doctrine_Query_Part"); /** * Doctrine_Query_From * * @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_From extends Doctrine_Query_Part { /** * DQL FROM PARSER * parses the from part of the query string * @param string $str * @return void */ public function parse($str) { $str = trim($str); $parts = Doctrine_Tokenizer::bracketExplode($str, 'JOIN'); $operator = false; switch (trim($parts[0])) { case 'INNER': $operator = ':'; case 'LEFT': array_shift($parts); break; } $last = ''; foreach ($parts as $k => $part) { $part = trim($part); if (empty($part)) { continue; } $e = explode(' ', $part); if (end($e) == 'INNER' || end($e) == 'LEFT') { $last = array_pop($e); } $part = implode(' ', $e); foreach (Doctrine_Tokenizer::bracketExplode($part, ',') as $reference) { $reference = trim($reference); $e = explode(' ', $reference); $e2 = explode('.', $e[0]); if ($operator) { $e[0] = array_shift($e2) . $operator . implode('.', $e2); } $table = $this->query->load(implode(' ', $e)); } $operator = ($last == 'INNER') ? ':' : '.'; } return null; } }