1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
<?php
$numeric = array("TINYINT", "SMALLINT", "MEDIUMINT", "INT", "INTEGER", "BIGINT", "REAL", "DOUBLE", "FLOAT", "DECIMAL", "NUMERIC");
class Row { var $name; var $type; var $maxlen; var $atributes; var $null; var $default; var $extra;
function Row($name, $type, $maxlen = "", $default = "", $attributes = "", $null = false, $extra = "") { $this->name = $name; $this->type = $type; $this->attributes = $attributes; $this->null = $null; $this->default =$default; $this->extra = $extra; $this->maxlen = $maxlen; }
function IsNumeric() { global $numeric; if(in_array($this->type, $numeric)) return true; return false; } }
class Table { var $name; var $rows;
function Table($tableName, $tableRows = null) { $this->name = $tableName; $this->rows = $tableRows; }
function AppendRow($row) { $this->rows[]=$row; }
function GetRowByName($name) { foreach($this->rows as $row) { if($row->name == $name) return $row; } return null; }
function GetRowByIndex($index) { return $this->rows[$index]; } function GetTableRows() { $retArr = array(); foreach($this->rows as $row) $retArr[] = $row->name; return $retArr; } }
function GetRowByField($field, $value, $from) { foreach($from as $item) { if($item->$field == $value) return $item; } return NULL; }
?>
|