FormToSQL.php
[Pman.Builder] / FormToSQL.php
1 <?php
2
3 // quick way to build SQL based on a form design..
4 // might have uses later...
5
6 require_once 'Pman.php';
7
8 class Pman_Builder_FormToSQL extends Pman {
9     
10     function getAuth(){
11         if (!HTML_FlexyFramework::get()->cli) {
12             die("not cli");
13         }
14         return true;
15     }
16     
17     function get()
18     {
19         //print_R($_SERVER['argv']);exit;
20         $file  = $_SERVER['argv'][2];
21         if (!file_exists($file)) {
22             die("file $file does not exist");
23            }
24         $o = json_decode(file_get_contents($file));
25         $this->walk($o);
26         die("DONE");
27     }
28     
29     function walk($o) 
30     {
31         
32         $this->parse($o);
33         
34         
35         
36         
37         foreach((array)$o as $k=>$v) {
38             if (is_array($v)) {
39                 foreach($v as $oo) {
40                     $this->walk($o);
41                 }
42                 
43                 continue;
44             }
45             if (is_object($v)) {
46                 $this->walk($v);
47                 continue;
48             }
49         }
50         
51     }
52     function parse($o) 
53     {
54         
55         if (empty($o->xtype)) {
56             return;
57         }
58         echo $o->xtype ."\n";
59         
60     }
61     
62 }