php匯出字典

來源:互聯網
上載者:User

標籤:function   public   created   中文   

public  function promotion_list()
    {
        $sql =     "CREATE TABLE `ka_sys` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT ‘自增ID‘,
  `sys_name` varchar(45) CHARACTER SET utf8 NOT NULL COMMENT ‘系統中文名稱‘,
  `eng_name` varchar(65) DEFAULT NULL,
  `sys_logo1` varchar(65) CHARACTER SET utf8 DEFAULT NULL COMMENT ‘大圖‘,
  `sys_logo2` varchar(65) CHARACTER SET utf8 DEFAULT NULL COMMENT ‘小圖‘,
  `sys_num` varchar(60) DEFAULT NULL,
  `created` int(11) NOT NULL COMMENT ‘建立時間‘,
  `updated` int(11) NOT NULL COMMENT ‘更新時間‘,
  `deleted` enum(‘1‘,‘0‘) NOT NULL DEFAULT ‘0‘ COMMENT ‘凍結‘,
  `parent_id` int(11) DEFAULT ‘0‘ COMMENT ‘系統父ID‘,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=53 DEFAULT CHARSET=latin1";
        preg_match_all("/(`.+`)(.+)(‘.+‘),/i",$sql,$out);
        echo ‘<pre>‘;
        print_r($out);
    }//
    
    public function create_database_doc()
    {
       //  /*
          header("Content-Type:   application/msword;charset=gbk");       
          header("Content-Disposition:   attachment;   filename=doc.doc");       
          header("Pragma:   no-cache");       
          header("Expires:   0");       
       
        
        // */
          
          $sql_query = "show tables;";
         
          $query     = $this->db->query($sql_query);
          $rowset    = $query->result_array();
          $tablearrs    = array();
          foreach($rowset as $key => $value)
          {
              $sql_query = "desc ". $value[‘Tables_in_ka‘];
           //   echo $sql_query;
              $query     = $this->db->query($sql_query);
              $reset     = $query->result_array();
              $this->get_notes($value[‘Tables_in_ka‘], $reset);
              $tablearrs[$key][‘tab_name‘] = $value[‘Tables_in_ka‘];
              $tablearrs[$key][‘feild_info‘] = $reset;
          }
          $output =‘‘;
          foreach ($tablearrs as $key => $value)
          {
                 $output   .=   ‘表‘.$tablearrs[$key][‘tab_name‘].PHP_EOL;
                $output    .=   ‘<table border="1" cellspacing="0" cellpadding="0"  width="90%" align="center">‘;    
                $output   .=   ‘<tr><td><strong>Field</strong></td>‘
                            . ‘<td><strong>Type</strong></td>‘
                            . ‘<td><strong>Null</strong></td>‘
                            . ‘<td><strong>Key</strong></td>‘
                            . ‘<td><strong>Default</strong></td>‘
                            . ‘<td><strong>Extra</strong></td>‘
                            . ‘<td><strong>notes</strong></td></tr>‘;   
                foreach ($tablearrs[$key][‘feild_info‘] as $ky => $val)
                {
                      $output   .=   ‘<tr><td>‘.$val[‘Field‘].‘</td>‘
                            . ‘<td>‘.$val[‘Type‘].‘</td>‘
                            . ‘<td>‘.$val[‘Null‘].‘</td>‘
                            . ‘<td>‘.$val[‘Key‘].‘</td>‘
                            . ‘<td>‘.$val[‘Default‘].‘</td>‘
                            . ‘<td>‘.$val[‘Extra‘].‘</td>‘
                            . ‘<td>‘.$val[‘notes‘].‘</td></tr>‘;
                }
                
               
                $output   .=   ‘</table>‘.PHP_EOL;
          }
         //   $output    =   mb_convert_encoding($output, "GBK","UTF-8");
          echo   $output;       
 
    }//end func create_database_doc
    
    public function get_notes($table_name,&$reset)
    {
         $sql_query = "show create table ".$table_name;
         //echo $sql_query;
         $query     = $this->db->query($sql_query);
         $rowset    = $query->result_array();
         $sql       = $rowset[0][‘Create Table‘];
         preg_match_all("/`(.+)`(.+)[‘(.*)‘],/i",$sql,$out);
     
         
         foreach ($reset as $key => $val)
         {                   
              @preg_match_all("/^(.*)\‘([^\‘]*)/i",$out[2][$key],$t_out);
              if( count($reset)-count($out[2])<=2)
              {
                  if(strpos($reset[$key][‘Field‘], ‘id‘)!==FALSE  && count($reset)-count($out[2])==1)
                       @preg_match_all("/^(.*)\‘([^\‘]*)/i",$out[2][$key-1],$t_out);
                      @$reset[$key][‘notes‘]  =$t_out[2][0];
              }
              else
              {
                    @$reset[$key][‘notes‘]  =‘‘;
              }
              
              
         }
      
         
         
    }//end func get_notes

php匯出字典

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.