cvs: pear /SQL_Parser Parser.php

From: Date: Wed, 06 Apr 2005 04:54:55 +0000
Subject: cvs: pear /SQL_Parser Parser.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-30967@lists.php.net to get a copy of this message
busterb Wed Apr 6 00:54:55 2005 EDT Modified files: /pear/SQL_Parser Parser.php Log: Allow updates to be set from identifiers as well as values (fix bug 4034) http://cvs.php.net/diff.php/pear/SQL_Parser/Parser.php?r1=1.27&r2=1.28&ty=u Index: pear/SQL_Parser/Parser.php diff -u pear/SQL_Parser/Parser.php:1.27 pear/SQL_Parser/Parser.php:1.28 --- pear/SQL_Parser/Parser.php:1.27 Sat Jul 3 00:49:44 2004 +++ pear/SQL_Parser/Parser.php Wed Apr 6 00:54:54 2005 @@ -23,7 +23,7 @@ // | John Griffin <jgriffin316@netscape.net> | // +----------------------------------------------------------------------+ // -// $Id: Parser.php,v 1.27 2004/07/03 04:49:44 busterb Exp $ +// $Id: Parser.php,v 1.28 2005/04/06 04:54:54 busterb Exp $ // require_once 'PEAR.php'; @@ -414,8 +414,15 @@ $this->lexer->unget(); break; default: - // parse for in-fix binary operators - if ($this->isReserved()) { + if ($this->isFunc()) { + $result = $this->parseFunctionOpts(); + if (PEAR::isError($result)) { + return $result; + } + $clause['arg_2']['value'] = $result; + $clause['arg_2']['type'] = 'function'; + } else if ($this->isReserved()) { + // parse for in-fix binary operators return $this->raiseError('Expected a column name or value'); } if ($this->token == '(') { @@ -620,16 +627,20 @@ return $this->raiseError('Expected a string or column name'); } break; - case 'avg': case 'min': case 'max': case 'sum': default: $this->getTok(); - $opts['arg'][] = $this->lexer->tokText; - $opts['type'][] = $this->token; + if ($this->token != ')') { + $opts['arg'][] = $this->lexer->tokText; + $opts['type'][] = $this->token; + } else { + $this->lexer->pushBack(); + } break; } + echo $this->token; $this->getTok(); if ($this->token != ')') { - return $this->raiseError('Expected ")"'); + return $this->raiseError('Expected ")" '); } // check for an alias @@ -643,7 +654,7 @@ } else { return $this->raiseError('Expected column alias'); } - } else { + } elseif ($this->token != null) { if ($this->token == 'ident' ) { $opts['alias'] = $this->lexer->tokText; } else { @@ -766,8 +777,8 @@ return $this->raiseError('Expected ='); } $this->getTok(); - if (!$this->isVal($this->token)) { - return $this->raiseError('Expected a value'); + if (!$this->isVal($this->token) && $this->token != 'ident') { + return $this->raiseError('Expected a value or column name'); } $tree['values'][] = array('value'=>$this->lexer->tokText, 'type'=>$this->token);

« previous php.pear.cvs (#30967) next »