Login   Register  
PHP Classes
elePHPant
Icontem

File: samples/function.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  >  samples/function.php  >  Download  
File: samples/function.php
Role: Example script
Content type: text/plain
Description: example for composing function with alias from the scratch
Class: SQL Parse and Compile
Parse and compose SQL queries programatically
Author: By
Last change: enhance sample for working on condition
Date: 5 years ago
Size: 1,121 bytes
 

Contents

Class file image Download
<?php

$sql 
'SELECT MAX(article) AS article FROM shop'

include_once(
"config.inc.php");

$sqlObject = new Sql_Parser($sql);
$parsedSQL $sqlObject->parse();

$sqlObject2 = new Sql_Compiler();

pdbg($parsedSQL"orange"__LINE__,__FILE__,100); 
pdbg($sqlObject2->compile($parsedSQL), "orange"__LINE__,__FILE__,100);


// from the scratch
$object = new Sql();
$object    ->setCommand("select")
        ->
addTableNames("shop")
        ->
setFunction
            
Sql::functionHelper(
                array(
                    
"max",
                    array(
                        array(
"Value"=>"article","Type"=>"ident")
                        ),
                    
"article"
                    
)
                ) 
        );

pdbg($object"orange"__LINE__,__FILE__); 
pdbg($object->compile(), "orange"__LINE__,__FILE__); 


##########################################################
$sql 'SELECT article, dealer, price FROM  shop WHERE  price=(SELECT MAX(price) FROM shop)'
$sqlObject = new Sql_Parser($sql);
$parsedSQL $sqlObject->parse();
$sqlObject2 = new Sql_Compiler();

pdbg($parsedSQL"lime"__LINE__,__FILE__,300); 
pdbg($sqlObject2->compile($parsedSQL), "lime"__LINE__,__FILE__,100);