cvs: pear /SQL_Parser Parser.php

From: Date: Wed, 18 Dec 2002 06:39:24 +0000
Subject: cvs: pear /SQL_Parser Parser.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-7923@lists.php.net to get a copy of this message
busterb Wed Dec 18 01:39:24 2002 EDT Modified files: /pear/SQL_Parser Parser.php Log: added better support for 'is' operators Index: pear/SQL_Parser/Parser.php diff -u pear/SQL_Parser/Parser.php:1.5 pear/SQL_Parser/Parser.php:1.6 --- pear/SQL_Parser/Parser.php:1.5 Wed Dec 18 00:59:28 2002 +++ pear/SQL_Parser/Parser.php Wed Dec 18 01:39:24 2002 @@ -18,7 +18,7 @@ // | Foundation, Inc., 59 Temple Place, Suite 330,Boston,MA 02111-1307 USA| // +----------------------------------------------------------------------+ // -// $Id: Parser.php,v 1.5 2002/12/18 05:59:28 busterb Exp $ +// $Id: Parser.php,v 1.6 2002/12/18 06:39:24 busterb Exp $ // require_once 'PEAR.php'; @@ -134,27 +134,7 @@ // {{{ isOperator() function isOperator() { - if (isset($this->operators[$this->token])) { - if ($this->token == 'is') { - $this->getTok(); - if ($this->token == 'null') { - $this->token = 'is null'; - return true; - } elseif ($this->token == 'not') { - $this->getTok(); - if ($this->token == 'null') { - $this->token = 'is not null'; - return true; - } else { - return false; - } - } - } else { - return true; - } - } else { - return false; - } + return isset($this->operators[$this->token]); } // }}} @@ -320,6 +300,7 @@ $clause['neg'] = true; $this->getTok(); } + if ($this->isReserved()) { return $this->raiseError('Expected a column name or value'); } @@ -333,13 +314,26 @@ } $clause['op'] = $this->token; - // parse the second argument $this->getTok(); - if ($this->isReserved()) { - return $this->raiseError('Expected a column name or value'); + // parse the special case for 'is' operators + if ($clause['op'] == 'is') { + if ($this->token == 'not') { + $clause['neg'] = true; + $this->getTok(); + } + if ($this->token != 'null') { + return $this->raiseError('Expected "null"'); + } + $clause['arg_2']['value'] = ''; + $clause['arg_2']['type'] = $this->token; + } else { + // parse for in-fix binary operators + if ($this->isReserved()) { + return $this->raiseError('Expected a column name or value'); + } + $clause['arg_2']['value'] = $this->lexer->tokText; + $clause['arg_2']['type'] = $this->token; } - $clause['arg_2']['value'] = $this->lexer->tokText; - $clause['arg_2']['type'] = $this->token; $this->getTok(); if (($this->token == 'and') || ($this->token == 'or')) { $op = $this->token;

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