27 if (!$cache->get($this->tables, array(
'id'=>
'tables'))) {
28 if (is_null($this->tables)) {
29 $this->tables = array();
30 $stmt = $this->
query(
'SHOW TABLES');
32 $this->tables[
'unprefix'] = array();
33 foreach($this->tables[
'raw'] as $r) {
34 $this->tables[
'unprefix'][$r] = $this->cfg->prefix ? str_replace($this->cfg->prefix,
'', $r) : $r;
39 return $this->tables[$unPrefix ?
'raw' :
'unprefix'];
49 if ($this->cfg->prefix) {
51 $index = array_search($table,
$tables);
67 if (!$cache->get($ret, array(
'id'=>
'fields-'.$table))) {
74 $fDefault =
'Default';
76 $fComment =
'Comment';
83 $unsigned = preg_match(
'/unsigned/', $row[$fType]);
87 $tmp = explode($this->cfg->sepCom, $row[$fComment]);
91 $tt = explode($this->cfg->sepComVal, $t);
93 $comment[$tt[0]] = $tt[1];
97 if (preg_match(
'/^(set|enum)\((.+)\)/', $row[$fType], $matches)) {
98 $row[$fType] = $matches[1];
99 $tmp = explode(
',',$matches[2]);
100 array_walk($tmp, create_function(
'&$t',
'$t = substr(substr($t, 0, strlen($t)-1), 1);'));
101 $precision = array();
104 }
else if (preg_match(
'/^((?:var)?char)\((\d+)\)/', $row[$fType], $matches)) {
105 if (substr($row[$fField], -5) ==
'_file') {
106 $row[$fType] =
'file';
109 $row[$fType] = $matches[1];
110 $length = $matches[2];
113 }
else if (preg_match(
'/^(decimal|float|double|decimal|dec|numeric|fixed)\((\d+),(\d+)\)/', $row[$fType], $matches)) {
114 $row[$fType] = $matches[1];
115 $length = $matches[2];
116 $precision = $matches[3];
117 }
else if (preg_match(
'/^((?:big|medium|small|tiny)?int)\((\d+)\)/', $row[$fType], $matches)) {
118 $row[$fType] = $matches[1];
119 $length = $matches[2];
120 }
else if (preg_match(
'/^((?:tiny|medium|long)?(text|blob))/', $row[$fType], $matches)) {
122 $htmlOut = !in_array(
'richtext', $comment);
124 if (strtoupper($row[$fKey]) ==
'PRI') {
127 $identity = ($row[$fExtra] ==
'auto_increment');
128 }
else if (strtoupper($row[$fKey]) ==
'UNI') {
138 if (strtoupper($row[$fDefault]) ==
'CURRENT_TIMESTAMP') {
139 $cf = create_function(
'',
'return time();');
140 $row[$fDefault] = $cf();
143 $ret[$row[$fField]] = array(
144 'name' => $row[$fField],
146 'type' => $row[$fType],
147 'default' => $row[$fDefault],
148 'required' => ($row[$fNull] ==
'NO'),
150 'precision' => $precision,
151 'unsigned' => $unsigned,
152 'primary' => $primary,
153 'primaryPos' => $primaryPos,
154 'identity' => $identity,
158 'htmlOut' => $htmlOut,
159 'comment' => $comment,
160 'rawComment' => $row[$fComment],
getTables($unPrefix=true)
query($sql, array $bind=array())