private function db_read_schema($schemafile)
    {
        $lines       = file($schemafile);
        $table_block = false;
        $schema      = array();
        $keywords    = array('PRIMARY','KEY','INDEX','UNIQUE','CONSTRAINT','REFERENCES','FOREIGN');

        foreach ($lines as $line) {
            if (preg_match('/^\s*create table ([\S]+)/i', $line, $m)) {
                $table_name = explode('.', $m[1]);
                $table_name = end($table_name);
                $table_name = preg_replace('/[`"\[\]]/', '', $table_name);
            }
            else if ($table_name && ($line = trim($line))) {
                if ($line == 'GO' || $line[0] == ')' || $line[strlen($line)-1] == ';') {
                    $table_name = null;
                }
                else {
                    $items = explode(' ', $line);
                    $col   = $items[0];
                    $col   = preg_replace('/[`"\[\]]/', '', $col);

                    if (!in_array(strtoupper($col), $keywords)) {
                        $type = strtolower($items[1]);
                        $type = preg_replace('/[^a-zA-Z0-9()]/', '', $type);

                        $schema[$table_name][$col] = $type;
                    }
                }
            }
        }

        return $schema;
    }