Login   Register  
PHP Classes
elePHPant
Icontem

File: Sql_Parser/Sql_ParserDelete.class.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Tom Schaefer  >  SQL Parse and Compile  >  Sql_Parser/Sql_ParserDelete.class.php  >  Download  
File: Sql_Parser/Sql_ParserDelete.class.php
Role: Class source
Content type: text/plain
Description: parses delete statement into object
Class: SQL Parse and Compile
Parse and compose SQL queries programatically
Author: By
Last change:
Date: 6 years ago
Size: 1,232 bytes
 

Contents

Class file image Download
<?php

/**
 *
 * Sql_ParserDelete
 * @package Sql
 * @subpackage Sql_Parser
 * @author Thomas Schäfer
 * @since 30.11.2008 07:49:30
 * @desc parses a sql delete into object
 */

/**
 *
 * Sql_ParserDelete
 * @package Sql
 * @subpackage Sql_Parser
 * @author Thomas Schäfer
 * @since 30.11.2008 07:49:30
 * @desc parses a sql delete into object
 */

class Sql_ParserDelete implements Sql_InterfaceParser {

    public static function 
doParse(){

        
Sql_Parser::getTok();
        
        if (
Sql_Object::token() != 'from') {
            return 
Sql_Parser::raiseError('Expected "from"');
        }
        
        
$tree = array('Command' => 'delete');
        
        
Sql_Parser::getTok();
        
        if (
Sql_Object::token() != 'ident') {
            return 
Sql_Parser::raiseError('Expected a table name');
        }
        
        
$tree['TableNames'][] = Sql_Object::lexer()->tokText;
        
        
Sql_Parser::getTok();
        
        if (
Sql_Object::token() != 'where') {
            return 
Sql_Parser::raiseError('Expected "where"');
        }
        
        
$clause Sql_Parser::parseSearchClause();
        
        if (
Sql_Parser::isError($clause)) {
            return 
$clause;
        }
        
$tree['Where'] = $clause;
        
        return 
$tree;
    }
    
    public static function 
parse() {
        return 
self::doParse();
    }

}