PHPSQLParser\builders\InsertStatementBuilder::build PHP Method

build() public method

public build ( array $parsed )
$parsed array
    public function build(array $parsed)
    {
        // TODO: are there more than one tables possible (like [INSERT][1])
        $sql = $this->buildINSERT($parsed['INSERT']);
        if (isset($parsed['VALUES'])) {
            $sql .= ' ' . $this->buildVALUES($parsed['VALUES']);
        }
        if (isset($parsed['SET'])) {
            $sql .= ' ' . $this->buildSET($parsed['SET']);
        }
        if (isset($parsed['SELECT'])) {
            $sql .= ' ' . $this->buildSELECT($parsed);
        }
        return $sql;
    }

Usage Example

 public function create($parsed)
 {
     $k = key($parsed);
     switch ($k) {
         case 'UNION':
         case 'UNION ALL':
             throw new UnsupportedFeatureException($k);
             break;
         case 'SELECT':
             $builder = new SelectStatementBuilder();
             $this->created = $builder->build($parsed);
             break;
         case 'INSERT':
             $builder = new InsertStatementBuilder();
             $this->created = $builder->build($parsed);
             break;
         case 'REPLACE':
             $builder = new ReplaceStatementBuilder();
             $this->created = $builder->build($parsed);
             break;
         case 'DELETE':
             $builder = new DeleteStatementBuilder();
             $this->created = $builder->build($parsed);
             break;
         case 'UPDATE':
             $builder = new UpdateStatementBuilder();
             $this->created = $builder->build($parsed);
             break;
         case 'RENAME':
             $builder = new RenameStatementBuilder();
             $this->created = $builder->build($parsed);
             break;
         case 'SHOW':
             $builder = new ShowStatementBuilder();
             $this->created = $builder->build($parsed);
             break;
         case 'CREATE':
             $builder = new CreateStatementBuilder();
             $this->created = $builder->build($parsed);
             break;
         case 'BRACKET':
             $builder = new BracketStatementBuilder();
             $this->created = $builder->build($parsed);
             break;
         case 'DROP':
             $builder = new DropStatementBuilder();
             $this->created = $builder->build($parsed);
             break;
         default:
             throw new UnsupportedFeatureException($k);
             break;
     }
     return $this->created;
 }