Login   Register  
PHP Classes
elePHPant
Icontem

File: Sql_Compiler/Sql_CompilerDelete.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_Compiler/Sql_CompilerDelete.class.php  >  Download  
File: Sql_Compiler/Sql_CompilerDelete.class.php
Role: Class source
Content type: text/plain
Description: compile delete statement
Class: SQL Parse and Compile
Parse and compose SQL queries programatically
Author: By
Last change:
Date: 5 years ago
Size: 1,358 bytes
 

Contents

Class file image Download
<?php

/**
 *
 * Sql_CompilerDelete
 * @package Sql_Compiler
 * @author Thomas Schäfer
 * @since 03.12.2008 07:49:30
 * @desc compiles sql delete statements into string
 */
/**
 *
 * Sql_CompilerDelete
 * @package Sql_Compiler
 * @author Thomas Schäfer
 * @since 03.12.2008 07:49:30
 * @desc compiles sql delete statements into string
 */
class Sql_CompilerDelete implements Sql_InterfaceCompiler
{

    
/**
     * compile delete
     *     
     * @desc build an delete statement string
     * @access private
     * @param string $type
     * @return string
     */
    
public static function doCompile() 
    {
        
$sql     Sql_Compiler::SQL_DELETE 
                
Sql_Compiler::SPACE 
                
Sql_Compiler::SQL_FROM
                
Sql_Compiler::SPACE 
                
implode(Sql_Compiler::COMMA Sql_Compiler::SPACESql_Object :: get('tree.TableNames') );

        
// save the where clause
        
if (Sql_Object :: has('tree.Where')) {
            
            
$search_string Sql_Compiler::compileSearchClause (Sql_Object :: get('tree.Where'));
            
            if (
Sql_Compiler::isError($search_string)) {
                return 
$search_string;
            }
            
$sql     .= Sql_Compiler::SPACE
                    
Sql_Compiler::SQL_WHERE
                    
Sql_Compiler::SPACE
                    
$search_string;
        }
        return 
$sql;
        
    }
    
    public static function 
compile$tree )
    {
        
Sql_Object::set("tree"$tree);
        return 
self::doCompile();
    }

}