4 require_once 'DB/DataObject/Generator.php';
7 class HTML_FlexyFramework_Generator extends DB_DataObject_Generator
9 // block class generation.
10 var $generateClasses = false;
12 function generateClasses()
14 if (!$this->generateClasses) {
17 parent::generateClasses();
21 function generateReaders()
23 $options = &PEAR::getStaticProperty('DB_DataObject','options');
26 foreach($this->tables as $this->table) {
27 $this->table = trim($this->table);
29 $out = array_merge($out, $this->_generateReader($this->table));
33 //echo '<PRE>';print_r($out);exit;
35 file_put_contents($options["ini_{$this->_database}"] . '.reader', serialize($out));
38 function _generateReader($table)
40 $DB = $this->getDatabaseConnection();
41 $dbtype = $DB->phptype;
42 $def = $this->_definitions[$table] ;
45 switch (strtoupper($t->type)) {
48 case 'INT2': // postgres
49 case 'INT4': // postgres
50 case 'INT8': // postgres
51 case 'SERIAL4': // postgres
52 case 'SERIAL8': // postgres
61 $ret[$table.'.'.$t->name] = array('type' => 'int');
66 case 'DOUBLE PRECISION': // double precision (firebird)
68 case 'FLOAT4': // real (postgres)
69 case 'FLOAT8': // double precision (postgres)
71 case 'MONEY': // mssql and maybe others
73 case 'NUMBER': // oci8
74 $ret[$table.'.'.$t->name] = array('type' => 'float'); //???
80 $ret[$table.'.'.$t->name] = array('type' => 'boolean'); //???
81 // postgres needs to quote '0'
82 if ($dbtype == 'pgsql') {
83 ///$type += DB_DATAOBJECT_STR;
94 case 'SET': // not really but oh well
96 case 'POINT': // mysql geometry stuff - not really string - but will do..
98 case 'TIMESTAMPTZ': // postgres
99 case 'BPCHAR': // postgres
100 case 'INTERVAL': // postgres (eg. '12 days')
102 case 'CIDR': // postgres IP net spec
103 case 'INET': // postgres IP
104 case 'MACADDR': // postgress network Mac address.
106 case 'INTEGER[]': // postgres type
107 case 'BOOLEAN[]': // postgres type
113 case 'BLOB': /// these should really be ignored!!!???
118 case 'CLOB': // oracle character lob support
120 case 'BYTEA': // postgres blob support..
121 $ret[$table.'.'.$t->name] = $t->name; // strings are not sent as arrays..
122 // $type = DB_DATAOBJECT_STR;
129 $ret[$table.'.'.$t->name] = array('type' => 'date', 'dateFormat' => 'Y-m-d'); //???
133 $ret[$table.'.'.$t->name] = $t->name; // technically not...
138 $ret[$table.'.'.$t->name] = array('type' => 'date', 'dateFormat' => 'Y-m-d H:i:s'); //???
141 case 'TIMESTAMP': // do other databases use this???
143 $ret[$table.'.'.$t->name] = ($dbtype == 'mysql') ?
144 array('type' => 'float') :
145 array('type' => 'date', 'dateFormat' => 'Y-m-d H:i:s');
153 $ret[$table.'.'.$t->name] = $t->name;