Beispiel #1
0
 if ($t) {
     $stmt = DbWrapper::exec("SHOW FULL TABLES LIKE ?", array("%{$t}%"));
 } else {
     $stmt = DbWrapper::exec("SHOW FULL TABLES");
 }
 $f = _get('field_like');
 // 获得表的注释,并将列表存在数组里
 $tables = array();
 while ($row = $stmt->fetch(PDO::FETCH_NUM)) {
     $table = $row[0];
     $arr = explode(' ', $row[1]);
     $type = end($arr);
     if (preg_match('/#/', $table)) {
         continue;
     }
     $create = DbWrapper::getCreate($table);
     $rs = preg_match("/ENGINE=.+COMMENT='(.+)'\$/", $create, $matches);
     $comment = $rs ? $matches[1] : '';
     $table_info = compact('table', 'type', 'comment', 'create');
     $found = true;
     if ($f) {
         $found = false;
         // 这里可以用 like 语句-
         $fields = DbWrapper::getFields($table);
         foreach ($fields as $field) {
             if (preg_match('/' . $f . '/', $field['Field'])) {
                 $table_info['find_field'] = $found = true;
                 $table_info['field_matches'][] = $field;
             }
         }
     }