Advertisement
joernneumeyer

Functional Query Builder

Jan 24th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.52 KB | None | 0 0
  1. <?php
  2.   function make_query_builder_select(): Closure {
  3.     $memory = [
  4.       'tables' => []
  5.     ];
  6.  
  7.     $builder = function(string $instruction) use (&$memory, &$builder) {
  8.       $instructionParameters = explode(' ', $instruction);
  9.       $instruction = array_shift($instructionParameters);
  10.  
  11.       switch ($instruction) {
  12.         case 'from':
  13.  
  14.           break;
  15.  
  16.         default:
  17.           throw new Exception("Unknown instruction '{$instruction}'!");
  18.       }
  19.       return $builder;
  20.     };
  21.  
  22.     return $builder;
  23.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement